﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Web;
using System.Xml;
using Wholesaler.Models.DBModels;
using Yunzuan.Common;
using Yunzuan.Common.Interface;
using Yunzuan.Common.Log;
using Yunzuan.Foundation.DataAccess;
using Yunzuan.Foundation.Entities;
using Yunzuan.Foundation.Log;
using Yunzuan.Foundation.Serializer;
using Yunzuan.Foundation.Web;
using Yunzuan.Foundation.Web_api;
using YunZuan.Models;
namespace DistributionService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“Distribution”。
    // 注意: 为了启动 WCF 测试客户端以测试此服务，请在解决方案资源管理器中选择 Distribution.svc 或 Distribution.svc.cs，然后开始调试。
    public class Distribution : IDistribution
    {
        string logParam; 
        /// <summary>
        /// 分销商列表 10-12
        /// </summary>
        /// <param name="getCustomersParam"></param>
        /// <returns></returns>
        public string GetDistributors(string getDistributorsParam)
        {
            return CWholesalers.GetDistributors<CustomerInfo>(getDistributorsParam);
        }
        /// <summary>
        /// 上传模式（0覆盖 1追加）
        /// </summary>
        public string UploadFileState(string uploadFileStateParam)
        {
            return AllPublic.UploadFileState(uploadFileStateParam);
        }
        public string ModifyExchange(string modifyExchangeParam)
        {
            return AllPublic.ModifyExchange(modifyExchangeParam);
        }
        #region  祼钻订单相关
        /// <summary>
        /// (单个操作)采购订单（处理（1下单成功，待采购）的订单到 (2采购成功，待入库)） --含事务    （改变订单状态 从1到2）
        /// </summary>
        /// <param name="purchaseOrdersParam"></param>
        /// <returns></returns>
        public string PurchaseOrder(string purchaseOrderParam)
        {
            return CWholesalers.PurchaseOrder(purchaseOrderParam);
        }
        /// <summary>
        /// （单个操作）备注订单 (销售员备注、采购员备注、物流员备注)  --含事务
        /// </summary>
        /// <param name="remarkOrdersParam"></param>
        /// <returns></returns>
        public string RemarkOrder(string remarkOrderParam)
        {
            return CWholesalers.RemarkOrder(remarkOrderParam);
        }
        /// <summary>
        /// 单个订单改价(单个操作 卖出退点 卖出RMB)
        /// </summary>
        /// <param name="reviseOrderParam"></param>
        /// <returns></returns>
        public string ReviseAnOrder(string reviseAnOrderParam)
        {
            return CWholesalers.ReviseAnOrder(reviseAnOrderParam);
        }
        /// <summary>
        /// 修改订单运费￥ 11-11
        /// </summary>
        /// <param name="freightParam"></param>
        /// <returns></returns>
        public string ModFreight(string freightParam)
        {
            return AllPublic.ModFreight<OrderInfo>(freightParam);
        }
        /// <summary>
        /// 批量订单改价(单个或多个操作 卖出退点+1 或卖出RMB*95折)
        /// </summary>
        /// <param name="reviseOrdersParam"></param>
        /// <returns></returns>
        public string ReviseOrders(string reviseOrdersParam)
        {
            return AllPublic.ReviseOrders<OrderInfo>(reviseOrdersParam);
        }
        /// <summary>
        /// 入库订单（处理（2采购成功，待入库）的订单到 (3入库成功，待出库)） --含事务   （改变订单状态 从2到3）
        /// </summary>
        /// <param name="arrivalOrdersParam"></param>
        /// <returns></returns>
        public string ArrivalOrders(string arrivalOrdersParam)
        {
            return AllPublic.ArrivalOrders<OrderInfo, CustomerInfo>(arrivalOrdersParam);
        }
        /// <summary>
        /// 取消入库
        /// </summary>
        /// <param name="cancelArrivalOrdersParam"></param>
        /// <returns></returns>
        public string CancelArrivalOrders(string cancelArrivalOrdersParam)
        {
            return CWholesalers.CancelArrivalOrders(cancelArrivalOrdersParam);
        }
        /// <summary>
        /// 制作出货单
        /// </summary>
        /// <param name="addShipParam"></param>
        /// <returns></returns>
        public string AddShip(string addShipParam)
        {
            return CWholesalers.AddShip(addShipParam);
        }
        /// <summary>
        /// 出货
        /// </summary>
        /// <param name="editShipParam"></param>
        /// <returns></returns>
        public string EditShip(string editShipParam)
        {
            return CWholesalers.EditShip(editShipParam);
        }
        /// <summary>
        /// 确认出货
        /// </summary>
        /// <param name="shipParam"></param>
        /// <returns></returns>
        public string Shipment(string shipParam)
        {
            return CWholesalers.Shipment(shipParam);
        }
        /// <summary>
        /// 退回订单
        /// </summary>
        /// <param name="stockOrdersParam"></param>
        /// <returns></returns>
        public string ReturnOrders1(string returnOrdersParam)
        {
            return CWholesalers.ReturnOrders1(returnOrdersParam);
        }
        /// <summary>
        /// 自留订单
        /// </summary>
        /// <param name="cancelOrdersParam"></param>
        /// <returns></returns>
        public string StockOrders1(string stockOrdersParam)
        {
            return CWholesalers.StockOrders1(stockOrdersParam);
        }
        /// <summary>
        /// 作废订单（1下单成功，采购中） --含事务     （改变订单状态 从1到10）
        /// </summary>
        /// <param name="cancelOrdersParam"></param>
        /// <returns></returns>
        public string CancelOrders(string cancelOrdersParam)
        {
            return CWholesalers.CancelOrders(cancelOrdersParam);
        }
        //转移客户 9-24
        public string ModifySalesUserID(string modifySalesUserIDParam)
        {
            return CWholesalers.ModifySalesUserID(modifySalesUserIDParam);
        }
        /// <summary>
        /// 转移订单（修改采购）--含事务        （不改变订单状态）
        /// </summary>
        /// <param name="modifyPurchaseUserIDParam"></param>
        /// <returns></returns>
        public string ModifyPurchaseUserID(string modifyPurchaseUserIDParam)
        {
            return CWholesalers.ModifyPurchaseUserID(modifyPurchaseUserIDParam);
        }
        /// <summary>
        /// 批量删除购物车
        /// </summary>
        /// <param name="submmitOrderParam"></param>
        /// <returns></returns>
        public string DeleteAllCart(string cartParam)
        {
            return CommonCart.DelCartInfo(GoodsType.Diamond, cartParam);
        }
        /// <summary>
        /// 订单列表(客户和团队)  -- 纯粹读数据 无需 事务
        /// </summary>
        /// <param name="getOrdersParam"></param>
        /// <returns></returns>
        public string GetOrders(string getOrdersParam)
        {
            return CWholesalers.GetOrders(getOrdersParam);
        }
        /// <summary>
        /// 裸钻订单结算(团队) 11-2   eegia 计算方法 其他需采取定制
        /// </summary>
        /// <param name="getOrdersParam"></param>
        /// <returns></returns>
        public string SettleOrders(string settleOrdersParam)
        {
            return CWholesalers.SettleOrders(settleOrdersParam);
        }
        /// <summary>
        /// 付款
        /// </summary>
        /// <param name="receiptOrdersParam"></param>
        /// <returns></returns>
        public string ReceiptOrders(string receiptOrdersParam)
        {
            return CWholesalers.ReceiptOrders(receiptOrdersParam);
        }
        /// <summary>
        /// 退回供应商收款
        /// </summary>
        /// <returns></returns>
        public string PayBackOrders(string paybackOrdersParam)
        {
            return CWholesalers.PayBackOrders(paybackOrdersParam);
        }
        /// <summary>
        /// 余额收款（1.更新订单支付状态为1已支付，2.更新客户余额） 12-10 (重中之重)
        /// </summary>
        /// <param name="stockOrdersParam"></param>
        /// <returns></returns>
        public string PayOrders(string payOrdersParam)
        {
            return CWholesalers.PayOrders(payOrdersParam);
        }
        /// <summary>
        /// 美金余额付款 2017-01-18
        /// </summary>
        /// <param name="payUSDOrdersParam"></param>
        /// <returns></returns>
        public string PayUSDOrders(string payUSDOrdersParam)
        {
            return CWholesalers.PayUSDOrders(payUSDOrdersParam);
        }
        /// <summary>
        /// 取消到货 2017-02-20
        /// </summary>
        /// <param name="cancelArrivalOrdersParam"></param>
        /// <returns></returns>
        public string CancelArrivalOrders1(string cancelArrivalOrdersParam)
        {
            return CWholesalers.CancelArrivalOrders1(cancelArrivalOrdersParam);
        }
        /// <summary>
        /// 确认到货 2017-02-21
        /// </summary>
        /// <param name="arrivalOrdersParam"></param>
        /// <returns></returns>
        public string ArrivalOrders1(string arrivalOrdersParam)
        {
            return CWholesalers.ArrivalOrders1(arrivalOrdersParam);
        }
        /// <summary>
        /// 订单确认到货-取消到货（A.确认到货：1.更新订单状态为3待出货，2.从HK-美金账户支出取货款$ ; B.取消到货 : 1.更新订单状态为2待到货，2.HK-美金账户收入取货款$） 12-9 (重中之重)
        /// </summary>
        /// <param name="arrivalOrdersParam"></param>
        /// <returns></returns>
        public string ArrivalOrders2(string arrivalOrdersParam)
        {
            return CWholesalers.ArrivalOrders2(arrivalOrdersParam);
        }
        /// <summary>
        /// 订单自留（1.更新订单状态为6已自留，2.将客户已支付￥退还到客户余额，3.回裸钻库存） 12-9 (重中之重)
        /// </summary>
        /// <param name="stockOrdersParam"></param>
        /// <returns></returns>
        public string StockOrders2(string stockOrdersParam)
        {
            return CWholesalers.StockOrders2(stockOrdersParam);
        }
        public string StockOrders(string stockOrdersParam)
        {
            return CWholesalers.StockOrders(stockOrdersParam);
        }
        /// <summary>
        /// 退回
        /// </summary>
        /// <param name="returnOrdersParam"></param>
        /// <returns></returns>
        public string ReturnOrders(string returnOrdersParam)
        {
            return CWholesalers.ReturnOrders(returnOrdersParam);
        }
        /// <summary>
        /// 订单退回（1.更新订单状态为7已退回，2.收回取货款$到HK-美金账户(真实账户、虚拟账户Type=1)，3.将客户已支付￥退还到客户余额） 12-9     （重中之重）
        /// </summary>
        /// <param name="returnOrdersParam"></param>
        /// <returns></returns>
        public string ReturnOrders2(string returnOrdersParam)
        {
            return CWholesalers.ReturnOrders2(returnOrdersParam);
        }
        #endregion
        private static readonly object objSubmitOrder = new object();
        /// <summary>
        /// 提交订单  --含事务
        /// </summary>
        /// <param name="submmitOrderParam"></param>
        /// <returns></returns>
        public string SubmitOrder(string submmitOrderParam)
        {
            HashParam param = Yunzuan.Foundation.Serializer.Json.Deserialize<HashParam>(submmitOrderParam);
            string tttagKey = CommonUrl.getURL(param,submmitOrderParam, "提交订单");
            StringBuilder sbMsg = new StringBuilder();
            lock (typeof(Distribution))
            {
                //{"CustomerID":"1","OrderType":2,"InventoryIDs":"13242637","Remarks":"123456717","PublicKey":"VHZqK1N1d01YVFh2eDhHTjlVaTU5Yk1GNEFaU0thOWg_1","PublicParentUrl":"http://88gia.com/"}-错误信息：可为空的对象必须具有一个值。
                var orderInfoMessage = "提交订单1——提交参数：" + submmitOrderParam;
                sbMsg.Append(orderInfoMessage + "\r\n");
                logParam = submmitOrderParam;
                StringBuilder tempSns = new StringBuilder();
                int addOrderResult = 0;//生成订单结果
                TransmissionOrderResult submitOrderResult1 = new TransmissionOrderResult();
                try
                {
                    #region
                    var failCount = 0;
                    var successCount = 0;
                    var failCount1 = 0;
                    var successCount1 = 0;
                    #endregion
                    //检测分销参数
                    if (param.ContainsKey("PublicParentUrl") && param.ContainsKey("PublicKey"))
                    {
                        var publicParentUrl = param["PublicParentUrl"].ToString(); //不要把这些信息带到一级批发系统
                        var publicKey = param["PublicKey"].ToString();
                        param.Remove("PublicParentUrl");
                        //str.Remove("PublicKey");
                        param["PublicKey"] = "open_Interface"; //传递给对应一级做区别
                        var inventoryJson = JsonConvert.SerializeObject(param);
                        //提交到对应一级的接口
                        var responseJson = MyHttpRequest.HttpRequest(string.Format("{0}Api/Open/SubmitOrder/?token={1}", publicParentUrl, publicKey), inventoryJson);
                        orderInfoMessage += "\r\nresponseJson:" + responseJson;
                        Dictionary<string, object> responseDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(responseJson);
                        if (responseDict["msgcode"].ToString().ToLower() == "true")
                        {
                            //采购人列表，取出循环里面的单个db连接
                            IList<HashResult> purchaseAgents = YZ.GetDatabase(tttagKey).QueryForList<HashResult>("User.getPurchaseAgentIds", null);
                            var purchaseAgentsDict = purchaseAgents.ToDictionary(key => key["UserName"], val => val["UserID"]);
                            //IDictionary<int, string> getPurchaseAgentIds = YZ.GetDatabase(tttagKey).QueryForDictionary<int, string>("User.getPurchaseAgentIds", "", "UserID");
                            //return null; 
                            //用来操作移除非现货供应商的货
                            List<int> list = param.GetString("InventoryIDs").TrimEnd(',').Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Int32.Parse).ToList();// new System.Collections.ArrayList(InventoryIDs);
                            if (list.Count <= 0) return CommonLog.MsgErrorInfo("未选择任何订单");
                            if (param.GetString("CustomerID") == "undefined" || param.GetString("CustomerID") == "")
                            { //客户登录信息消失或失效
                                return CommonLog.MsgErrorInfo("客户登录失效");//CustomerID一定要存在
                            }
                            if (!param.ContainsKey("OrderType"))
                            { //客户登录信息消失或失效
                                return CommonLog.MsgErrorInfo("OrderType error");//OrderType一定要存在
                            }
                            CustomerInfo _customerInfo = YZ.GetDatabase(tttagKey).Get<CustomerInfo>(param.GetInt("CustomerID"));
                            orderInfoMessage += string.Format("提交订单2——客户信息{0}--退点：{1}，彩色退点：{2},优惠：{3}", _customerInfo.UserName, _customerInfo.Rebate, _customerInfo.FancyRebate, _customerInfo.Discounts);
                            sbMsg.Append(orderInfoMessage + "\r\n");
                            if (_customerInfo == null)
                            {
                                return CommonLog.MsgErrorInfo("客户标识不存在");//CustomerID一定要存在
                            }
                            else
                            {
                                #region
                                orderInfoMessage += "提交订单3——数据中心格式化后信息:" + inventoryJson;
                                sbMsg.Append(orderInfoMessage + "\r\n");
                                //var responseJson = MyHttpRequest.ConvertToInventoryFormat(inventoryJson); //转化成库存的Json格式
                                Dictionary<string, object> root = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(responseDict["msginfo"]));//转成PageList
                                PageList<InventoryInfoResult> _SoldInventoryInfos = JsonConvert.DeserializeObject<PageList<InventoryInfoResult>>(JsonConvert.SerializeObject(root["Successful"]));//转成PageList
                                list = JsonConvert.DeserializeObject<List<int>>(JsonConvert.SerializeObject(root["Failed"]));//获取失败清单
                                orderInfoMessage += "提交订单4——数据中心格式化InventoryInfoResult后信息:" + JsonConvert.SerializeObject(_SoldInventoryInfos);
                                sbMsg.Append(orderInfoMessage + "\r\n");
                                //计算客户及用户看到的价格
                                SysSettingInfo setting = GoodsType.GetSystemSetting(tttagKey, GoodsType.Diamond);
                                DiamondsPriceHandlers diamondspricehandlers = new DiamondsPriceHandlers();
                                int j = 0;
                                foreach (var item in _SoldInventoryInfos.Data)
                                {
                                    //item.SourceDiscountReturn =item.CustomerDiscountReturn; //分销的原退点等于一级客户的客户退点
                                    //item.SourceDolarPerCarat = item.CustomerDolarPerCarat;  //同上
                                    //item.SourceDolarPerGrain = item.CustomerDolarPerGrain;  //同上
                                    //if (item.PurchaseTime != null && item.PurchaseTime.Value.Year == 1970) item.PurchaseTime = null;
                                    //if (item.ArrivalTime != null && item.ArrivalTime.Value.Year == 1970) item.ArrivalTime = null;
                                    //white#round#0.1-0.3##-2; 
                                    diamondspricehandlers.ComputePrice(item, _customerInfo, setting, tttagKey);//计算分销对应客户的价格
                                    orderInfoMessage += string.Format("提交订单5——设置信息 币种：{0},销售汇率：{1},采购汇率：{2},全局退点（白）：{3},全局退点（彩）：{4}，分组折扣（白）：{5},分组折扣（彩）：{6},分组倍率：{7}"
                                                                                   , setting.CurrentSet, setting.Rate, setting.PurchaseExchangerate, setting.GlobalDiscountReturn, setting.GlobalFancyDiscountReturn, setting.Group4C, setting.GroupFancy4C, setting.GroupAmount);
                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                    //单粒库存
                                    //InventoryInfoResult item = (InventoryInfoResult)_SoldInventoryInfos.Data[j];//必须是InventoryInfoResult类型    
                                    orderInfoMessage += "提交订单7[" + j + "]—_inventoryInfo信息:" + JsonConvert.SerializeObject(item);
                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                    var orderParam = new OrderInfo() { InventoryID = item.ID, CertNo = item.CertNo };
                                    OrderInfo _order = YZ.GetDatabase(tttagKey).QueryForObject<OrderInfo>("Order.SelectOrderByInventoryID", orderParam);
                                    if (_order == null)  //防止重复正常的订单 12345为正常的订单
                                    {
                                        //检查是否在失败列表里面
                                        if (list.Contains((int)item.ID)) break; //list为失败清单
                                        //赋值
                                        #region  本地订单添加
                                        _order = new OrderInfo();
                                        _order.CreateTime = DateTime.Now;//下单时间 
                                        //分销付款状态等不能用批发的
                                        if (item.Supplier.ToUpper() == tttagKey)
                                        {
                                            //检查到货时间是否为空
                                            if (!string.IsNullOrEmpty(item.ArrivalTime))
                                            {
                                                //现货
                                                _order.OrderStatus = 3;//订单状态 3（待出货）
                                                //_order.DeliveryTime = DateTime.Now;//发货时间 2017-02-10 
                                                //_order.ArrivalTime = item.ArrivalTime;
                                                //_order.Arrival = 1;//
                                            }
                                            else
                                            {
                                                _order.OrderStatus = 2;
                                            }
                                            //现货特有  买入时间，到货时间，付款状态，备注，采购人
                                            if (!string.IsNullOrEmpty(item.PurchaseTime))
                                                //_order.PurchaseTime = Convert.ToDateTime(item.PurchaseTime);//买入时间
                                                _order.Remarks = param.GetString("Remarks").Replace(" ", ""); //客户下单备注 (去除空格 255长度)
                                            //_order.ReceiptStatus = item.ReceiptStatus;//付款状态
                                            if (!string.IsNullOrEmpty(item.PurchaseAgent))
                                            {
                                                if (purchaseAgentsDict.ContainsKey(item.PurchaseAgent))
                                                    _order.PurchaseUserID = Convert.ToInt32(purchaseAgentsDict[item.PurchaseAgent]);
                                            }
                                        }
                                        else
                                        {
                                            _order.ReceiptStatus = 0;//付款状态
                                            //定货
                                            _order.OrderStatus = 1;//订单状态 1（下单成功，采购中）
                                        }
                                        _order.PaymentStatus = 0;//收款状态 0
                                        _order.CustomerID = param.GetInt("CustomerID") ?? 0;  //客户ID
                                        //默认没有采购了，所以注释先 
                                        //if (userinfo != null)
                                        //    _order.PurchaseUserID = userinfo.UserID;
                                        _order.SalesUserID = Convert.ToInt32(_customerInfo.SalesUserID);//销售ID
                                        _order.OrderType = param.GetInt("OrderType");//订单类型 (1客主 2代客 3 录入 4 二级） 9-10
                                        _order.SN = item.SN;//货号
                                        _order.InventoryID = item.ID;//库存ID
                                        _order.OriginSN = item.OriginSN;//原货号
                                        _order.Weight = item.Weight;//重量
                                        _order.CertNo = item.CertNo;//证书号
                                        _order.SupplierCode = item.Supplier;//供应商
                                        _order.Color = item.Color;//颜色
                                        _order.Clarity = item.Clarity;//净度
                                        _order.Symmetry = item.Symmetry;//对称
                                        _order.Polish = item.Polish;//抛光
                                        _order.IsFancy = item.IsFancy;//是否彩钻
                                        _order.CertType = item.CertType;//证书类型
                                        _order.Fluorescence = item.Fluorescence;//荧光
                                        _order.Place = item.Place;//所在地
                                        _order.Milky = item.Milky;//奶油
                                        _order.BlackDefect = item.BlackDefect;//黑点
                                        _order.Hue = item.Hue;//色调
                                        _order.HA = item.HA;//心箭
                                        _order.OtherDefect = item.OtherDefect;//其他瑕疵
                                        _order.EyeClean = item.EyeClean;//肉眼干净
                                        _order.Measurement = item.Measurement;//尺寸  
                                        _order.Shape = item.Shape;//形状
                                        _order.Cut = item.Cut;//切工
                                        _order.Rapnet = item.Rapnet;//国际报价（数据中心订单Rapnet始终为null）
                                        _order.Status = item.Status;//货品状态 8-19
                                        _order.PurchaseSupplier = item.PurchaseSupplier;//采购供应商
                                        //_order.PurchaseAgent= _inventoryInfo.PurchaseAgent;
                                        _order.PurchaseExchangerate = GoodsType.GetPurchaseExchangeRate(setting);//采购汇率 
                                        _order.PriceUSD = item.SourceDolarPerGrain;//买入美金总价
                                        _order.PurchaseRMB = _order.PriceUSD * _order.PurchaseExchangerate;
                                        _order.ConfirmUSD = item.CustomerDolarPerGrain.Value * _customerInfo.Discounts.Value;//卖出美金 = 客户美金总价 2017-01-19
                                        _order.DiscountReturn = item.SourceDiscountReturn;//买入退点
                                        _order.MediaID = item.MediaID;
                                        _order.HasImage = item.HasImage;
                                        _order.HasVideo = item.HasVideo;
                                        _order.HasAtlas = item.HasAtlas;
                                        //卖出价格
                                        _order.SalesExchangerate = GoodsType.GetRate(setting);//销售汇率 
                                        _order.ConfirmPrice = _order.ConfirmUSD.Value * _order.SalesExchangerate.Value;//最后成交卖出人民币总价 *优惠
                                        //买入价格 
                                        orderInfoMessage += "提交订单8[" + j.ToString() + "]——_order信息:" + JsonConvert.SerializeObject(_order);
                                        sbMsg.Append(orderInfoMessage + "\r\n");
                                        //{"OriginSN":"F42","ShipNo":null,"Freight":null,"Status":1,"BlackDefect":"NA NA","Shape":1,"Color":"D","Clarity":"VVS2","Cut":"GD","Polish":"VG","Symmetry":"GD","Rapnet":14100.0,"Fluorescence":"N","CertType":"GIA","Place":"CHN","Measurement":"6.02-6.17x4.07","HA":"NA","Hue":"BR0 GR0","OtherDefect":"NA NA NA NA","EyeClean":"","Milky":"ML0","IsFancy":0,"OrderID":null,"OrderStatus":2,"OrderType":2,"InventoryID":13242632,"Online":null,"PriceUSD":5499.0,"PurchaseRMB":35083.620,"ReceiptPrice":null,"PaymentStatus":0,"ReceiptStatus":null,"CustomerID":1,"SupplierCode":"BZ","SalesUserID":926,"PurchaseUserID":0,"CreateTime":"2018-06-05T15:26:39.0530497+08:00","Remarks":null,"SalesExchangerate":6.56,"PurchaseExchangerate":6.38,"DeliveryTime":null,"ShipTime":null,"Arrival":null,"CurType":null,"ArrivalTime":null,"PayTime":null,"RecTime":null,"Confirmdiscount":null,"DiscountReturn":-61.0,"SN":"G123456712","Weight":1.0,"CertNo":"123456712","Shenback":null,"ConfirmPrice":37923.36000000,"ConfirmUSD":5781.000000,"PurchaseRemarks":null,"GoodsRemark":null,"SalesRemarks":null,"ShipRemarks":null,"PurchaseTime":"0001-01-01T00:00:00","OrderIds":null,"PurchaseSupplier":null,"BuyDis":null,"BuyUSDPrice":null,"BuyRMBPrice":null}
                                        _order.Confirmdiscount = AllPublic.CalcWhiteReturnPoint(_order.IsFancy, _order.ConfirmUSD, _order.Rapnet, _order.Weight, _customerInfo.Discounts, _order.PriceUSD);//最后成交退点
                                        //新增原供应商
                                        _order.PurchaseSupplier = item.PurchaseSupplier;
                                        //分销没有现货概念
                                        //if (_order.SupplierCode.ToUpper() == tttagKey)
                                        //{
                                        //    _order.BuyDis = item.PurchaseDiscountReturn.Value;
                                        //    _order.BuyRMBPrice = Math.Round(item.PurchaseRMB.Value, 3); //Math.Round(_inventoryInfo.PurchaseUSDPerGrain.Value * _order.SalesExchangerate.Value, 3);
                                        //    _order.BuyUSDPrice = Math.Round(item.PurchaseUSDPerGrain.Value, 3);
                                        //}
                                        orderInfoMessage += "提交订单9[" + j.ToString() + "]——_order信息:" + JsonConvert.SerializeObject(_order);
                                        sbMsg.Append(orderInfoMessage + "\r\n");
                                        //有至少一个成功下单，将有两大事务：生成本地订单和移除购物车
                                        #endregion
                                        using (ITransaction trans_addOrder = YZ.GetTransaction(tttagKey))
                                        {
                                            //执行
                                            #region  执行事物，删除购物车
                                            try
                                            {
                                                addOrderResult = trans_addOrder.Add(_order);//生成单条订单 
                                                //单条订单生成成功,就移除购物车。
                                                if (addOrderResult > 0)
                                                {
                                                    if (j == 0)  //加入1个sn
                                                        tempSns.Append(_order.SN);
                                                    //现货 
                                                    try
                                                    {
                                                        //立即购买 流程
                                                        try
                                                        {
                                                            int[] cartIds = { (int)item.ID };//这个是用来批量删除购物车的id
                                                            //删除购物车中的商品
                                                            CommonCart.DelCartInfo(GoodsType.Diamond, tttagKey, param.GetInt("CustomerID"), cartIds);
                                                            trans_addOrder.CommitTransaction(); //当购物车移除成功，就同时触发生成本地订单和移除购物车（这个东西有效，可利用）
                                                            successCount++;
                                                            orderInfoMessage += "提交订单10[" + j.ToString() + "]成功" + "——_order信息:" + JsonConvert.SerializeObject(_order);
                                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                                        }
                                                        catch (Exception exc)
                                                        {
                                                            CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), exc);
                                                            trans_addOrder.RollBackTransaction();//回滚事务
                                                            failCount++;
                                                            orderInfoMessage += "提交订单异常1[" + j.ToString() + "]" + "——_order信息:" + JsonConvert.SerializeObject(_order) + "异常信息==>" + exc.StackTrace;
                                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        failCount++;
                                                        CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                                                        orderInfoMessage += "提交订单异常2[" + j.ToString() + "]" + JsonConvert.SerializeObject(_order) + "异常信息==>" + ex.StackTrace;
                                                        sbMsg.Append(orderInfoMessage + "\r\n");
                                                        return CommonLog.MsgErrorInfo("移除购物车：程序错误：");
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                failCount++;
                                                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                                                orderInfoMessage += "提交订单异常3[" + j.ToString() + "]" + JsonConvert.SerializeObject(_order) + "异常信息==>" + ex.StackTrace;
                                                sbMsg.Append(orderInfoMessage + "\r\n");
                                                return CommonLog.MsgErrorInfo("生成订单，程序错误");
                                            }
                                            #endregion
                                        }
                                        j++;
                                    }
                                    else
                                    {
                                        failCount++;
                                    }
                                    #endregion
                                }
                                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), null, orderInfoMessage);
                                if (successCount == 0 && successCount1 == 0 && failCount == 0 && failCount1 == 0)
                                {
                                    failCount = list.Count;
                                }
                                var msg = new
                                {
                                    Successful = successCount,
                                    Successful1 = successCount1,
                                    Failed = failCount,
                                    Failed1 = failCount1,
                                };
                                if (successCount > 0)//成功则发送短信
                                {
                                    UserInfo userInfo = new UserInfo();
                                    if (_customerInfo.SalesUserID != null)
                                    {
                                        userInfo = YZ.GetDatabase(tttagKey).Get<UserInfo>(_customerInfo.SalesUserID.Value);
                                        if (userInfo != null)
                                        {
                                            #region
                                            var snStr = tempSns.ToString();
                                            var orderType = param.GetInt("OrderType");//订单类型 (1客主 2代客 3 录入 4 二级） 9-10
                                            if (userInfo.Mobile != null)
                                            {
                                                // > 10  有可能有国外号码
                                                if (AllPublic.IsPhoneNo(userInfo.Mobile) && orderType == 1)
                                                {
                                                    CWholesalers.SendMsg(userInfo.Mobile, userInfo.RealName, _customerInfo.NickName, snStr);  //业务
                                                    orderInfoMessage += "提交订单12 成功后发送消息给业务员，业务员信息:" + JsonConvert.SerializeObject(userInfo);
                                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                                }
                                                if (userInfo.Mobile != _customerInfo.Mobile && AllPublic.IsPhoneNo(_customerInfo.Mobile) && orderType == 2) //客户
                                                {
                                                    CWholesalers.SendMsg(_customerInfo.Mobile, "", "您", snStr);
                                                    orderInfoMessage += "提交订单13 成功后发送消息给客户，客户信息:" + JsonConvert.SerializeObject(_customerInfo);
                                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                                }
                                                //if (userInfo.Mobile != _customerInfo.Mobile && userInfo.Mobile != tel && tel.Length > 10)
                                                //    SendMsg(tel, "管理员", _customerInfo.NickName, snStr);//admin
                                            }
                                            #endregion
                                        }
                                        else
                                        {
                                            orderInfoMessage += "提交订单14 下单成功，发短信失败，客户对应的用户已不存在！客户对应的ID是:" + _customerInfo.SalesUserID.Value;
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                            CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), null, "下单成功，发短信失败，客户对应的用户已不存在！");
                                        }
                                    }
                                    else
                                    {
                                        Link link = YZ.GetDatabase(tttagKey).Get<Link>(1);//系统管理员号码
                                        var tel = "";
                                        if (link != null)
                                            tel = link.Telphone.ToString();
                                        if (tel.Length > 10 && AllPublic.IsPhoneNo(tel))
                                        {
                                            CWholesalers.SendMsg(tel, "管理员", _customerInfo.NickName, tempSns.ToString());//admin 
                                            orderInfoMessage += "提交订单15 发短信给管理员，管理员电话:" + tel + ";客户昵称:" + _customerInfo.NickName + "货号:" + tempSns.ToString();
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                        }
                                    }
                                }
                                orderInfoMessage += "提交订单16 成功，返回消息" + JsonConvert.SerializeObject(msg);
                                sbMsg.Append(orderInfoMessage + "\r\n");
                                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), null, orderInfoMessage);
                                return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(msg));
                            }
                        }
                        else
                        {
                            return CommonLog.MsgErrorInfo(responseDict["msgcode"].ToString());
                        }
                    }
                    else
                    {
                        return CommonLog.MsgErrorInfo("缺少参数");
                    }
                }
                catch (Exception ex)
                {
                    orderInfoMessage += "提交订单17异常，消息：" + ex.StackTrace;
                    CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                    return CommonLog.MsgErrorInfo("提交订单：程序错误：");
                }
                finally
                {
                    CommonLog.SendMQMsg(tttagKey, sbMsg.ToString());
                }
            }
        }
        /// <summary>
        /// 录入订单 9-6
        /// </summary>
        /// <param name="entryOrderParam"></param>
        /// <returns></returns>
        public string EntryOrder(string entryOrderParam)
        {
            return CWholesalers.EntryOrder(entryOrderParam);
        }
        /// <summary>
        /// 打印出货单 9-20
        /// </summary>
        /// <param name="deliveryOrdersParam"></param>
        /// <returns></returns>
        public string PrintShipOrders(string printShipOrdersParam)
        {
            return CWholesalers.PrintShipOrders(printShipOrdersParam);
        }
        /// <summary>
        /// 打印出货单 9-20
        /// </summary>
        /// <param name="deliveryOrdersParam"></param>
        /// <returns></returns>
        public string GetPrintShipOrders(string printShipOrdersParam)
        {
            return CWholesalers.GetPrintShipOrders(printShipOrdersParam);
        }
        /// <summary>
        /// 获取出货单订单
        /// </summary>
        /// <returns></returns>
        public string GetShipOrders(string getShipOrdersParam)
        {
            return CWholesalers.GetShipOrders(getShipOrdersParam);
        }
        /// <summary>
        /// 订单支付
        /// </summary>
        /// <param name="editShipNoParam"></param>
        /// <returns></returns>
        public string PayOrders1(string payOrdersParam)
        {
            return CWholesalers.PayOrders1(payOrdersParam);
        }
        //删除现货订单 （备用表，非订单表）
        public string DelOrdersByOwner(string delOrdersParam)
        {
            return CWholesalers.NewDelOrders(delOrdersParam, true);
        }
        /// <summary>
        /// 删除订单 9-29
        /// </summary>
        /// <param name="payOrdersParam"></param>
        /// <returns></returns>
        public string DelOrders(string delOrdersParam)
        {
            return CWholesalers.NewDelOrders(delOrdersParam, false);
        }
        /// <summary>
        /// 导出我的订单（仅客户）
        /// </summary>
        /// <param name="downloadOrderParam"></param>
        /// <returns></returns>
        public string ExportOrders(string exportOrdersParam)
        {
            return CWholesalers.ExportOrders(exportOrdersParam);
        }
        /// <summary>
        /// 导出 今日取货单 （仅管理员和物流）
        /// </summary>
        /// <param name="exportDeliveryOrderParam"></param>
        /// <returns></returns>
        public string DeliveryOrders(string deliveryOrdersParam)
        {
            return CWholesalers.DeliveryOrders(deliveryOrdersParam);
        }
        /// <summary>
        /// 获取单个订单信息
        /// </summary>
        /// <param name="customerInfoParam"></param>
        /// <returns></returns>
        public string GetOrderInfo(string orderInfoParam)
        {
            return CWholesalers.GetOrderInfo(orderInfoParam);
        }
        /// <summary>
        /// 支付出货单
        /// </summary>
        /// <param name="payShipNoParam"></param>
        /// <returns></returns>
        public string EditShipNo(string editShipNoParam)
        {
            return CWholesalers.EditShipNo(editShipNoParam);
        }
        /// <summary>
        /// 导出所有订单（仅管理员）
        /// </summary>
        /// <param name="downloadAllOrderParam"></param>
        /// <returns></returns>
        public string ExportAllOrder(string exportAllParam)
        {
            return CWholesalers.ExportAllOrder(exportAllParam);
        }
        /// <summary>
        /// 导出裸钻
        /// </summary>
        /// <param name="exportParam"></param>
        /// <returns></returns>
        public string GetExportUrl(string exportParam)
        {
            return CWholesalers.GetExportUrl(exportParam);
        }
        /// <summary>
        /// 查看取货单
        /// </summary>
        /// <returns></returns>
        public string GetDeliverys(string getDeliverysParam)
        {
            return CWholesalers.GetDeliverys(getDeliverysParam);
        }
        /// <summary>
        /// 查询到货日期
        /// </summary>
        /// <param name="getDeliverysParam"></param>
        /// <returns></returns>
        public string GetArrivals(string getArrivalsParam)
        {
            return CWholesalers.GetArrivals(getArrivalsParam);
        }
        //录单
        /// <summary>
        /// 录入的参数是否重复 9-27
        /// </summary>
        /// <returns></returns>
        public string EntryCheck(string entryCheckParam)
        {
            return CWholesalers.EntryCheck(entryCheckParam);
        }
        /// <summary>
        /// 导出销售订单（团队）
        /// </summary>
        /// <param name="downloadOrderParam"></param>
        /// <returns></returns>
        public string DownloadOrder(string downloadOrderParam)
        {
            return CWholesalers.DownloadOrder(downloadOrderParam);
        }
        /// <summary>
        /// 导出销售和采购订单（团队）
        /// </summary>
        /// <returns></returns>
        public string DownloadAllOrder(string downloadAllOrderParam)
        {
            return CWholesalers.DownloadAllOrder(downloadAllOrderParam);
        }
        /// <summary>
        /// 导出录单模板
        /// </summary>
        /// <returns></returns>
        public string DownEntryTemplate(string param)
        {
            return CWholesalers.DownEntryTemplate(param);
        }
        #region 客户相关
        /// <summary>
        /// 所有客户 9-6
        /// </summary>
        /// <param name="getCustomersParam"></param>
        /// <returns></returns>
        public string GetCustomerList(string getCustomerListParam)
        {
            return CWholesalers.GetCustomerList(getCustomerListParam);
        }
        /// <summary>
        /// 客户列表------ 纯粹读数据 无需 事务
        /// </summary>
        /// <param name="getOrdersParam"></param>
        /// <returns></returns>
        public string GetCustomers(string getCustomersParam)
        {
            return CWholesalers.GetCustomers(getCustomersParam);
        }
        /// <summary>
        ///  统计客户状态数量
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string StatisticsCustomer(string strParam)
        {
            return CWholesalers.StatisticsCustomer(strParam);
        }
        /// <summary>
        //客户修改密码（公司客户）
        /// </summary>
        /// <param name="customerModifyPasswordParam"></param>
        /// <returns></returns>
        public string CustomerModifyPassword(string customerModifyPasswordParam)
        {
            return CWholesalers.CustomerModifyPassword(customerModifyPasswordParam);
        }
        /// <summary>
        //客户生成key
        /// </summary>
        /// <param name="customerModifyPasswordParam"></param>
        /// <returns></returns>
        public string CustomerModifyCustomerKey(string customerModifyCustomerKeyParam)
        {
            return CWholesalers.CustomerModifyCustomerKey(customerModifyCustomerKeyParam);
        }
        /// <summary>
        //客户重置密码验证（公司客户）
        /// </summary>
        /// <param name="customerForgotPasswordParam"></param>
        /// <returns></returns>
        public string CustomerForgotPassword(string customerForgotPasswordParam)
        {
            return CWholesalers.CustomerForgotPassword(customerForgotPasswordParam);
        }
        /// <summary>
        /// (单个操作)添加客户（公司客户） --含事务
        /// </summary>
        /// <param name="addCustomerParam"></param>
        /// <returns></returns>
        public string AddCustomer(string addCustomerParam)
        {
            return CWholesalers.AddCustomer(addCustomerParam);
        }
        /// <summary>
        /// 获取单个客户资料（公司客户)
        /// </summary>
        /// <param name="customerInfoParam"></param>
        /// <returns></returns>
        public string GetCustomerInfo(string customerInfoParam)
        {
            return CWholesalers.GetCustomerInfo(customerInfoParam);
        }
        /// <summary>
        /// 客户注册是否存在（公司客户）
        /// </summary>
        /// <param name="customerRegIsExistParam"></param>
        /// <returns></returns>
        public string CustomerRegIsExist(string customerRegIsExistParam, string key = "")
        {
            return CWholesalers.CustomerRegIsExist(customerRegIsExistParam, key);
        }
        /// <summary>
        /// 客户注册（公司客户）
        /// </summary>
        /// <param name="customerRegisterParam"></param>
        /// <returns></returns>
        public string CustomerRegister(string customerRegisterParam)
        {
            return CWholesalers.CustomerRegister(customerRegisterParam);
        }
        /// <summary>
        /// 客户登录（公司客户）
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public string CustomerLogin(string customerLoginParam)
        {
            return CWholesalers.CustomerLogin(customerLoginParam);
        }
        /// <summary>
        /// (单个操作)修改客户（公司客户） --含事务
        /// </summary>
        /// <param name="editCustomerParam"></param>
        /// <returns></returns>
        public string EditCustomer(string editCustomerParam)
        {
            return CWholesalers.EditCustomer(editCustomerParam);
        }
        /// <summary>
        /// 审核客户 从待审核2到正常1
        /// </summary>
        /// <param name="editCustomerParam"></param>
        /// <returns></returns>
        public string ActiveCustomer(string activeCustomerParam)
        {
            return CWholesalers.ActiveCustomer(activeCustomerParam);
        }
        /// <summary>
        /// 编辑客户优惠
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string UpdateCustomerDiscounts(string strParam)
        {
            return CWholesalers.UpdateCustomerDiscounts(strParam);
        }
        #endregion
        #region 团队业务相关
        /// <summary>
        /// 团队登录（公司员工）
        /// </summary>
        /// <param name="teamLoginParam"></param>
        /// <returns></returns>
        public string UserLogin(string userLoginParam)
        {
            return CWholesalers.UserLogin(userLoginParam);
        }
        /// <summary>
        /// (单个操作)添加团队（公司团队） --含事务
        /// </summary>
        /// <param name="addCustomerParam"></param>
        /// <returns></returns>
        public string AddUser(string addUserParam)
        {
            return CWholesalers.AddUser(addUserParam);
        }
        /// <summary>
        /// (单个操作)修改团队（公司团队） --含事务
        /// </summary>
        /// <param name="editCustomerParam"></param>
        /// <returns></returns>
        public string EditUser(string editUserParam)
        {
            return CWholesalers.EditUser(editUserParam);
        }
        /// <summary>
        /// 团队修改密码 9-21
        /// </summary>
        /// <param name="customerModifyPasswordParam"></param>
        /// <returns></returns>
        public string TeamModifyPassword(string teamModifyPasswordParam)
        {
            return CWholesalers.TeamModifyPassword(teamModifyPasswordParam);
        }
        /// <summary>
        /// 团队列表 --- -- 纯粹读数据 无需 事务
        /// </summary>
        /// <param name="getCustomersParam"></param>
        /// <returns></returns>
        public string GetUsers(string getUsersParam)
        {
            return CWholesalers.GetUsers(getUsersParam);
        }
        /// <summary>
        /// 所有业务 9-6
        /// </summary>
        /// <param name="getSalesParam"></param>
        /// <returns></returns>
        public string GetSaleList(string getSaleListParam)
        {
            return CWholesalers.GetSaleList(getSaleListParam);
        }
        /// <summary>
        /// 业务列表 RoleID = 3 (8-19)
        /// </summary>
        /// <param name="getUsersParam"></param>
        /// <returns></returns>
        public string GetSales(string getSalesParam)
        {
            return CWholesalers.GetSales(getSalesParam);
        }
        /// <summary>
        /// 所有采购（业务+采购）
        /// </summary>
        /// <param name="getPurchasesParam"></param>
        /// <returns></returns>
        public string GetPurchaseList(string getPurchaseListParam)
        {
            return CWholesalers.GetPurchaseList(getPurchaseListParam);
        }
        /// <summary>
        /// 纯采购列表 9-26
        /// </summary>
        /// <param name="getPurchaseListParam"></param>
        /// <returns></returns>
        public string GetPurchasers(string getPurchasersParam)
        {
            return CWholesalers.GetPurchasers(getPurchasersParam);
        }
        /// <summary>
        /// 采购列表 RoleID = 4 (8-19)
        /// </summary>
        /// <param name="getSalesParam"></param>
        /// <returns></returns>
        public string GetPurchases(string getPurchasesParam)
        {
            return CWholesalers.GetPurchases(getPurchasesParam);
        }
        /// <summary>
        /// 团队添加是否存在（公司团队）
        /// </summary>
        /// <param name="customerRegIsExistParam"></param>
        /// <returns></returns>
        public string UserRegIsExist(string userRegIsExistParam)
        {
            return CWholesalers.UserRegIsExist(userRegIsExistParam);
        }
        /// <summary>
        /// 获取单个员工资料（公司员工)
        /// </summary>
        /// <param name="customerInfoParam"></param>
        /// <returns></returns>
        public string GetUserInfo(string userInfoParam)
        {
            return CWholesalers.GetUserInfo(userInfoParam);
        }
        #endregion 业务相关end
        #region 财务相关
        /// <summary>
        /// 银行账户列表 12-8
        /// </summary>
        /// <param name="getFlowsParam"></param>
        /// <returns></returns>
        public string GetBanks(string getBanksParam)
        {
            return CWholesalers.GetBanks(getBanksParam);
        }
        /// <summary>
        /// 银行账户列表 12-21
        /// </summary>
        /// <param name="getBankListParam"></param>
        /// <returns></returns>
        public string GetBankList(string getBankListParam)
        {
            return CWholesalers.GetBankList(getBankListParam);
        }
        /// <summary>
        /// 银行账户
        /// </summary>
        /// <param name="getBankParam"></param>
        /// <returns></returns>
        public string GetBank(string getBankParam)
        {
            return CWholesalers.GetBank(getBankParam);
        }
        /// <summary>
        /// 添加账户
        /// </summary>
        /// <param name="addBankParam"></param>
        /// <returns></returns>
        public string AddBank(string addBankParam)
        {
            return CWholesalers.AddBank(addBankParam);
        }
        /// <summary>
        /// 修改银行账户 12-13
        /// </summary>
        /// <param name="editBankParam"></param>
        /// <returns></returns>
        public string EditBank(string editBankParam)
        {
            return AllPublic.EditBank(editBankParam);
        }
        /// <summary>
        /// 流水列表 12-3
        /// </summary>
        /// <param name="getAccountsParam"></param>
        /// <returns></returns>
        public string GetFlows(string getFlowsParam)
        {
            return CWholesalers.GetFlows(getFlowsParam);
        }
        /// <summary>
        /// 账户转出
        /// </summary>
        /// <param name="bankTransferParam"></param>
        /// <returns></returns>
        public string BankTransfer(string bankTransferParam)
        {
            return CWholesalers.BankTransfer(bankTransferParam);
        }
        /// <summary>
        /// 直接账户充值 01-05
        /// </summary>
        /// <param name="directChargeParam"></param>
        /// <returns></returns>
        public string DirectCharge(string directChargeParam)
        {
            return CWholesalers.DirectCharge(directChargeParam);
        }
        /// <summary>
        /// 客户充值 (0申请充值 1直接充值)
        /// </summary>
        /// <param name="addChargeParam"></param>
        /// <returns></returns>
        public string AddCharge(string addChargeParam)
        {
            return CWholesalers.AddCharge(addChargeParam);
        }
        /// <summary>
        /// 获取单条记账明细
        /// </summary>
        /// <returns></returns>
        public string GetChargeInfo(string chargeInfoParam)
        {
            return CWholesalers.GetChargeInfo(chargeInfoParam);
        }
        /// <summary>
        /// 客户充值（1直接充值 -1 作废充值）
        /// </summary>
        /// <param name="editChargeParam"></param>
        /// <returns></returns>
        public string EditCharge(string editChargeParam)
        {
            return CWholesalers.EditCharge(editChargeParam);
        }
        /// <summary>
        /// 流水订单详情
        /// </summary>
        /// <returns></returns>
        public string GetOrderIDsDetail(string orderIDsParam)
        {
            return CWholesalers.GetOrderIDsDetail(orderIDsParam);
        }
        /// <summary>
        /// 客户充值
        /// </summary>
        /// <returns></returns>
        public string GetCharges(string getChargesParam)
        {
            return CWholesalers.GetCharges(getChargesParam);
        }
        /// <summary>
        /// 导出充值记录 12-3
        /// </summary>
        /// <param name="exportChargesParam"></param>
        /// <returns></returns>
        public string ExportCharges(string exportChargesParam)
        {
            return CWholesalers.ExportCharges(exportChargesParam);
        }
        /// <summary>
        /// 客户消费
        /// </summary>
        /// <param name="getChargesParam"></param>
        /// <returns></returns>
        public string GetPays(string getPaysParam)
        {
            return CWholesalers.GetPays(getPaysParam);
        }
        #region 流水
        /// <summary>
        /// 添加流水
        /// </summary>
        /// <param name="addExpenseParam"></param>
        /// <returns></returns>
        public string AddFlow(string addFlowParam)
        {
            return CWholesalers.AddFlow(addFlowParam);
        }
        /// <summary>
        /// 添加流水(已审核)
        /// </summary>
        /// <param name="addExpenseParam"></param>
        /// <returns></returns>
        public string AddFlowByPassStatus(string addFlowParam)
        {
            return CWholesalers.AddFlowByPassStatus(addFlowParam);
        }
        /// <summary>
        /// 修改流水 
        /// </summary>
        /// <param name="editFlowParam"></param>
        /// <returns></returns>
        public string EditFlow(string editFlowParam)
        {
            return CWholesalers.EditFlow(editFlowParam);
        }
        /// <summary> 
        /// 导出银行收支 12-10
        /// </summary>
        /// <param name="expFlowsParam"></param>
        /// <returns></returns>
        public string ExportFlows(string expFlowsParam)
        {
            return CWholesalers.ExportFlows(expFlowsParam);
        }
        /// <summary>
        /// 流水记录统计 12-13
        /// </summary>
        /// <param name="flowNumberParam"></param>
        /// <returns></returns>
        public string FlowNumber(string flowNumberParam)
        {
            return CWholesalers.FlowNumber(flowNumberParam);
        }
        /// <summary>
        /// 审核流水 Status 必须=0待审核 -多事务
        /// </summary>
        /// <param name="modifyFlowParam"></param>
        /// <returns></returns>
        public string ModifyFlow1(string modifyFlowParam)
        {
            return CWholesalers.ModifyFlow1(modifyFlowParam);
        }
        /// <summary>
        /// 单条流水
        /// </summary>
        /// <param name="chargeInfoParam"></param>
        /// <returns></returns>
        public string GetFlow(string getFlowParam)
        {
            return CWholesalers.GetFlow(getFlowParam);
        }
        /// <summary>
        /// 审核流水（1.更新流水为已审核1，2.更新银行账户结余，3.更新订单付款状态为已支付， 4.如果Type为3定金或4提现，还需更新客户余额） - 单事务 12-8 （重中之重）
        /// </summary>
        /// <param name="modifyFlowParam"></param>
        /// <returns></returns>
        public string ModifyFlow(string modifyFlowParam)
        {
            return CWholesalers.ModifyFlow(modifyFlowParam);
        }
        #endregion
        #endregion
        #region Notice通知相关
        /// <summary>
        /// 单个公告
        /// </summary>
        /// <param name="customerInfoParam"></param>
        /// <returns></returns>
        public string GetNoticeInfo(string noticeInfoParam)
        {
            return CWholesalers.GetNoticeInfo(noticeInfoParam);
        }
        /// <summary>
        /// 浏览公告
        /// </summary>
        /// <param name="noticeInfoParam"></param>
        /// <returns></returns>
        public string ViewNoticeInfo(string viewNoticeInfoParam)
        {
            return CWholesalers.ViewNoticeInfo(viewNoticeInfoParam);
        }
        /// <summary>
        /// 发布公告
        /// </summary>
        /// <param name="addCustomerParam"></param>
        /// <returns></returns>
        public string AddNotice(string addNoticeParam)
        {
            return CWholesalers.AddNotice(addNoticeParam);
        }
        /// <summary>
        /// 修改公告
        /// </summary>
        /// <param name="editCustomerParam"></param>
        /// <returns></returns>
        public string EditNotice(string editNoticeParam)
        {
            return CWholesalers.EditNotice(editNoticeParam);
        }
        /// <summary>
        /// 所有公告
        /// </summary>
        /// <param name="getCustomersParam"></param>
        /// <returns></returns>
        public string GetNotices(string getNoticesParam)
        {
            return CWholesalers.GetNotices(getNoticesParam);
        }
        /// <summary>
        /// 所有发布中公告 11-16
        /// </summary>
        /// <param name="getNoticesParam"></param>
        /// <returns></returns>
        public string GetNoticeList(string getNoticeListParam)
        {
            return CWholesalers.GetNoticeList(getNoticeListParam);
        }
        #endregion  
        #region 裸钻库存相关
        /// <summary>
        /// 获取单个在线库存
        /// </summary>
        /// <param name="inventoryInfoParam"></param>
        /// <returns></returns>
        public string GetInventoryInfo(string inventoryInfoParam, string key = "")
        {
            return CWholesalers.GetInventoryInfo(inventoryInfoParam, key);
        }
        public string GetInventoryInfosCount(string inventoryInfoParam)
        {
            return CWholesalers.GetInventoryInfosCount(inventoryInfoParam);
        }
        /// <summary>
        /// 获取多个在线库存数据 （公司客户和团队）
        /// </summary>
        /// <param name="inventoryInfoParam"></param>
        /// <returns></returns>
        public string GetInventoryInfos(string inventoryInfoParam, string key = "")
        {
            logParam = inventoryInfoParam;
            string tttagKey = "";
            string step = "";
            string _msgInfo = "{\"msgcode\":#code,\"msginfo\":\"#msg\",\"data\":#result}";
            try
            {
                HashParam str = JsonConvert.DeserializeObject<HashParam>(inventoryInfoParam);
                if (!string.IsNullOrEmpty(key))
                {
                    tttagKey = key;
                }
                else
                {
                    tttagKey = CommonUrl.getURL(str, inventoryInfoParam, "查询库存");
                }
                step = "Step1";
                string secondSN = "";
                if (str.ContainsKey("IsStock"))
                {
                    secondSN = ConfigurationManager.AppSettings[tttagKey + "SecondSN"];
                    str.Add("SecondSN", new string[1] { secondSN });
                }
                if (str.ContainsKey("PublicParentUrl") && str.ContainsKey("PublicKey"))
                {
                    CustomerInfo customerInfo = null;
                    if (str.ContainsKey("CustomerID")) //如果是客户查询，
                    {
                        int _customerId = 0;
                        int.TryParse(str["CustomerID"].ToString(), out _customerId);
                        customerInfo = YZ.GetDatabase(tttagKey).Get<CustomerInfo>(_customerId);//CustomerID值如存在，就按客户的价格；不存在就是团队的价格 
                    }
                    if (customerInfo != null && customerInfo.SearchCountFlag == 0)//param.UserID 表示只有客户自己查询
                    {
                        return _msgInfo.Replace("#code", "false").Replace("#msg", "你今天查询过多,暂无权限.").Replace("#result", JsonConvert.SerializeObject(""));
                    }
                    var publicParentUrl = str["PublicParentUrl"].ToString(); //不要把这些信息带到一级批发系统
                    var publicKey = str["PublicKey"].ToString();
                    str.Remove("PublicParentUrl");
                    str.Remove("PublicKey");
                    var inventoryJson = JsonConvert.SerializeObject(str);
                    step = "Step2  publicParentUrl=" + publicParentUrl + "                publicKey=" + publicKey + "               inventoryJson=" + inventoryJson;
                    var responseJson = MyHttpRequest.HttpRequest(string.Format("{0}Api/Open/QueryStock/?token={1}", publicParentUrl, publicKey), inventoryJson);
                    step = "Step3";
                    responseJson = responseJson.Replace("CustomerDiscountReturn", "SourceDiscountReturn")
                        .Replace("CustomerDolarPerCarat", "SourceDolarPerCarat")
                        .Replace("CustomerDolarPerGrain", "SourceDolarPerGrain");
                    Dictionary<string, object> responseDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(responseJson);
                    step = "Step4";
                    if (responseDict["msgcode"].ToString().ToLower() == "true")
                    {
                        step = "Step5";
                        Dictionary<string, object> responseDict2 = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(responseDict["data"]));
                        var result = JsonConvert.DeserializeObject<PageList<InventoryInfoResult>>(JsonConvert.SerializeObject(responseDict2));
                        step = "Step6";
                        //result = JsonConvert.DeserializeObject<PageList<InventoryInfoResult>>(responseJson); //解析结果，转成PageList<InventoryInfoResult>格式
                        //result不为null
                        if (result != null)
                        {
                            //搜索条件无结果
                            //if (result.TotalCount == 0)
                            //{
                            //    return _msgInfo.Replace("#code", "true").Replace("#msg", "没有任何记录").Replace("#result", JsonConvert.SerializeObject(result));
                            //}
                            //计算价格
                            #region
                            if (result.Data.Count > 0)  //非上传的货，计算价格
                            {
                                step = "Step7";
                                SysSettingInfo systemInfo = YZ.GetDatabase(tttagKey).QueryForObject<SysSettingInfo>("Syssetting.GetLooseSetting", null);//系统设置必须存在
                                if (systemInfo == null)
                                {
                                    return _msgInfo.Replace("#code", "false").Replace("#msg", "获取失败,请检查设置").Replace("#result", JsonConvert.SerializeObject(""));
                                }
                                //计算客户及用户看到的价格
                                SysSettingInfo setting = GoodsType.GetSystemSetting(tttagKey, GoodsType.Diamond);
                                DiamondsPriceHandlers diamondspricehandlers = new DiamondsPriceHandlers();
                                step = "Step8";
                                foreach (var item in result.Data)
                                {
                                    //if (item.PurchaseTime != null && item.PurchaseTime.Value.Year == 1970) item.PurchaseTime = null;
                                    //if (item.ArrivalTime != null && item.ArrivalTime.Value.Year == 1970) item.ArrivalTime = null;
                                    //white#round#0.1-0.3##-2; 
                                    diamondspricehandlers.ComputePrice(item, customerInfo, setting, tttagKey);//计算价格
                                }
                                step = "Step9";
                            }
                            return _msgInfo.Replace("#code", "true").Replace("#msg", "获取库存成功").Replace("#result", JsonConvert.SerializeObject(result));
                            #endregion
                        }
                        else
                        {
                            return _msgInfo.Replace("#code", "false").Replace("#msg", "获取库存失败:结果为null").Replace("#result", JsonConvert.SerializeObject(""));
                        }
                    }
                    else
                    {
                        return _msgInfo.Replace("#code", "false").Replace("#msg", "获取库存失败:结果为空").Replace("#result", JsonConvert.SerializeObject(responseDict));
                    }
                }
                else
                {
                    return _msgInfo.Replace("#code", "false").Replace("#msg", "获取库存失败:参数不正确").Replace("#result", JsonConvert.SerializeObject(""));
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：" + ex.StackTrace + "查询步骤：" + step);
                //日志：ex.Message
                return _msgInfo.Replace("#code", "false").Replace("#msg", "获取库存失败:数据中心接口繁忙").Replace("#result", JsonConvert.SerializeObject(""));
            }
        }
        #endregion
        #region 裸钻现货管理（单个添加 修改 删除 批量调整 裸钻上下架）
        /// <summary>
        /// 导出上传模板
        /// </summary>
        /// <returns></returns>
        public string DownTemplate(string param)
        {
            return AllPublic.DownTemplate(param);
        }
        /// <summary>
        /// 更新裸钻
        /// </summary>
        /// <param name="udateInventoryParam"></param>
        /// <returns></returns>
        public string ModifyDia(string modifyDiaParam)
        {
            return CWholesalers.ModifyDia(modifyDiaParam);
        }
        /// <summary>
        /// 新增裸钻
        /// </summary>
        /// <param name="udateInventoryParam"></param>
        /// <returns></returns>
        public string AddDia(string addDiaParam)
        {
            return CWholesalers.AddDia(addDiaParam);
        }
        /// <summary>
        /// 删除裸钻
        /// </summary>
        /// <param name="udateInventoryParam"></param>
        /// <returns></returns>
        public string DelDia(string delDiaParam)
        {
            return CWholesalers.DelDia(delDiaParam);
        }
        /// <summary>
        /// 批量修改裸钻价格
        /// </summary>
        /// <param name="udateInventoryParam"></param>
        /// <returns></returns>
        public string BatchDia(string batchDiaParam)
        {
            return CWholesalers.BatchDia(batchDiaParam);
        }
        /// <summary>
        /// 批量修改裸钻
        /// </summary>
        /// <param name="batchUpdateDiaParam"></param>
        /// <returns></returns>
        public string BatchUpdateDia(string batchUpdateDiaParam)
        {
            return CWholesalers.BatchUpdateDia(batchUpdateDiaParam);
        }
        /// <summary>
        ///  POST stocks/shelves/ 全部裸钻上架   ?IsFancy=1 全部彩钻上架
        /// </summary>
        /// <returns></returns>
        public string OnShelves(string param)
        {
            return AllPublic.OnShelves(param);
        }
        /// <summary>
        ///  Delete stocks/shelves/ 全部裸钻下架   ?IsFancy=1 全部彩钻下架
        /// </summary>
        /// <returns></returns>
        public string OffShelves(string param)
        {
            return AllPublic.OffShelves(param);
        }
        /// <summary>
        /// 裸钻库存批量修改（需要签名）
        /// </summary>
        /// <param name="udateInventoryParam"></param>
        /// <returns></returns>
        public string BatchUpStockData(string batchDiaParam)
        {
            return CWholesalers.BatchUpStockData(batchDiaParam);
        }
        #endregion
        #region 裸钻购物车相关
        /// <summary>
        /// 获取购物车货品详情列表
        /// </summary>
        /// <param name="cartInfoParam"></param>
        /// <returns></returns>
        public string GetCartInfos(string cartInfoParam)
        {
            return CWholesalers.GetCartInfos(cartInfoParam);
        }
        /// <summary>
        /// 获取购物车列表
        /// </summary>
        /// <param name="catsParam"></param>
        /// <returns></returns>
        public string GetCarts(string cartsParam)
        {
            //return CommonCart.SearchCartInfo(GoodsType.Diamond, cartsParam);
            return CWholesalers.GetCarts(cartsParam, GoodsType.Diamond);
        }
        /// <summary>
        /// 移出购物车
        /// </summary>
        /// <param name="removeFromCartParam"></param>
        /// <returns></returns>
        public string RemoveFromCart(string removeFromCartParam)
        {
            return CommonCart.DelCartInfo(GoodsType.Diamond, removeFromCartParam);
        }
        /// <summary>
        /// 添加购物车
        /// </summary>
        /// <param name="addToCartParam"></param>
        /// <returns></returns>
        public string AddToCart(string addToCartParam)
        {
            return CWholesalers.AddToCart(addToCartParam);
        }
        /// <summary>
        /// 添加购物车(单个或多个)  --含事务))))))))))))))
        /// </summary>
        /// <param name="multiAddToCartParam"></param>
        /// <returns></returns>
        public string MultiAddToCart(string multiAddToCartParam)
        {
            lock (typeof(Distribution))
            {
                return CommonCart.AddCartInfo(GoodsType.Diamond, multiAddToCartParam);
            }
        }
        #endregion
        #region 系统配置相关
        /// <summary>
        /// 修改配置
        /// </summary>
        /// <param name="editSysSettingInfoParam"></param>
        /// <returns></returns>
        public string EditSysSettingInfo(string editSysSettingInfoParam)
        {
            logParam = editSysSettingInfoParam;
            string tttagKey = CommonUrl.getURL(null,editSysSettingInfoParam, "修改配置");
            //SysSettingID（必传）
            //templateJSON
            SysSettingInfo param = Json.Deserialize<SysSettingInfo>(editSysSettingInfoParam);
            try
            {
                param.UpdateTime = DateTime.Now;//上次更新时间
                using (ITransaction trans_editSysSetting = YZ.GetTransaction(tttagKey))
                {
                    int editSysSettingResult = trans_editSysSetting.Edit(param);
                    if (editSysSettingResult > 0)
                    {
                        try
                        {
                            trans_editSysSetting.CommitTransaction();
                            for (int i = 1; i < 10; i++)
                            {
                                if (System.Web.HttpContext.Current.Cache.Get(tttagKey + "Cache:Group4C" + i.ToString()) != null)
                                    System.Web.HttpContext.Current.Cache.Remove(tttagKey + "Cache:Group4C" + i.ToString());
                            }
                            return CommonLog.MsgSuccessInfo("修改设置成功");
                        }
                        catch (Exception)
                        {
                            trans_editSysSetting.RollBackTransaction();//回滚事务
                        }
                    }
                    else
                    {
                        return CommonLog.MsgErrorInfo("修改设置失败，设置标识不存在");
                    }
                    return CommonLog.MsgErrorInfo("修改设置失败,请重试");
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：修改配置" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("修改客户失败，程序错误");
            }
        }
        /// <summary>
        /// 修改全局 11-10
        /// </summary>
        /// <param name="editNoticeParam"></param>
        /// <returns></returns>
        public string EditGlobal(string editGlobalParam)
        {
            logParam = editGlobalParam;
            string tttagKey = CommonUrl.getURL(null,editGlobalParam, "修改全局");
            //SysSettingID（必传）
            //templateJSON
            SysSettingInfo param = Json.Deserialize<SysSettingInfo>(editGlobalParam);
            try
            {
                param.UpdateTime = DateTime.Now;
                using (ITransaction trans_editGlobal = YZ.GetTransaction(tttagKey))
                {
                    int editGlobalResult = trans_editGlobal.Edit(param);
                    if (editGlobalResult > 0)
                    {
                        try
                        {
                            trans_editGlobal.CommitTransaction();
                            return CommonLog.MsgSuccessInfo("修改成功");
                        }
                        catch (Exception e)
                        {
                            trans_editGlobal.RollBackTransaction();
                            return CommonLog.MsgErrorInfo("修改失败:");
                        }
                    }
                    else
                    {
                        return CommonLog.MsgErrorInfo("修改失败，标识不存在");
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：修改全局" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("修改失败，程序错误");
            }
        }
        /// <summary>
        /// 修改全局的币种  
        /// </summary>
        /// <param name="editNoticeParam"></param>
        /// <returns></returns>
        public string EditGlobalCurrency(string editGlobalParam)
        {
            logParam = editGlobalParam;
            string tttagKey = CommonUrl.getURL(null,editGlobalParam, "修改全局的币种");
            //SysSettingID（必传）
            //templateJSON
            try
            {
                SysSettingInfo param = Json.Deserialize<SysSettingInfo>(editGlobalParam);
                if (param.CurrentSet > -1 && param.CurrentSet < 3) //0全部，1rmb，2usd
                {
                    try
                    {
                        int i = YZ.GetDatabase(tttagKey).Update("Syssetting.SetCurrency", param);
                        if (i > 0)
                        {
                            CommonLog.SendMQMsg(tttagKey, "修改全局的币种：成功" + editGlobalParam);
                            return CommonLog.MsgSuccessInfo("修改成功");
                        }
                        else
                        {
                            CommonLog.SendMQMsg(tttagKey, "修改全局的币种：失败" + editGlobalParam);
                            return CommonLog.MsgErrorInfo("修改失败");
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonLog.SendMQMsg(tttagKey, "异常信息：修改全局的币种" + ex.StackTrace + "参数:" + logParam);
                        return CommonLog.MsgErrorInfo("修改失败:");
                    }
                }
                else
                {
                    CommonLog.SendMQMsg(tttagKey, "修改全局的币种：失败" + editGlobalParam);
                    return CommonLog.MsgErrorInfo("修改失败，标识不存在");
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：修改全局的币种" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("保存失败，程序错误");
            }
        }
        /// <summary>
        /// 获取所有配置 
        /// </summary>
        /// <param name="sysSettingInfoParam"></param>
        /// <returns></returns>
        public string GetSysSettingInfo(string param)
        {
            logParam = param;
            string tttagKey =  CommonUrl.getURL(null,param);;
            //templateJSON
            try
            {
                SysSettingInfo setting = YZ.GetDatabase(tttagKey).QueryForObject<SysSettingInfo>("Syssetting.GetLooseSetting", null);
                if (setting != null)
                {
                    return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(setting));
                }
                else
                {
                    return CommonLog.MsgErrorInfo("加载失败");
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：获取所有配置" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("加载失败");
            }
        }
        /// <summary>
        /// 获取全局售出汇率
        /// </summary>
        /// <returns></returns>
        public string GetRate(string getRateParam)
        {
            logParam = getRateParam;
                HashParam param = Json.Deserialize<HashParam>(getRateParam);
            string tttagKey =  CommonUrl.getURL(param,getRateParam);;
            //SysSettingID
            string _msgInfo = "{\"msgcode\":#code,\"msginfo\":\"#msg\",\"data\":#result}"; //templateJSON
            try
            {
                SysSettingInfo setting = YZ.GetDatabase(tttagKey).QueryForObject<SysSettingInfo>("Syssetting.GetRate", param);//SysSettingID
                if (setting != null)
                {
                    return _msgInfo.Replace("#code", "true").Replace("#msg", "获取全局设置成功").Replace("#result", JsonConvert.SerializeObject(setting));
                }
                else
                {
                    return _msgInfo.Replace("#code", "false").Replace("#msg", "获取全局设置失败,无标识").Replace("#result", JsonConvert.SerializeObject(""));
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：获取全局售出汇率" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("程序错误");
            }
        }
        /// <summary>
        /// 获取采购汇率
        /// </summary>
        /// <returns></returns>
        public string GetExchangeRate(string param)
        {
            logParam = param;
            string tttagKey =  CommonUrl.getURL(null,param);;
            string _msgInfo = "{\"msgcode\":#code,\"msginfo\":\"#msg\",\"data\":#result}"; //templateJSON
            try
            {
                SysSettingInfo setting = YZ.GetDatabase(tttagKey).QueryForObject<SysSettingInfo>("Syssetting.GetRate", 1);//SystemID=1裸钻设置
                if (setting != null)
                {
                    return _msgInfo.Replace("#code", "true").Replace("#msg", "获取成功").Replace("#result", JsonConvert.SerializeObject(setting));
                }
                else
                {
                    return _msgInfo.Replace("#code", "false").Replace("#msg", "获取失败:请检查配置标识").Replace("#result", JsonConvert.SerializeObject(""));
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：获取采购汇率" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("程序错误：");
            }
        }
        /// <summary>
        /// 单个全局
        /// </summary>
        /// <param name="noticeInfoParam"></param>
        /// <returns></returns>
        public string GetSettingInfo(string settingInfoParam)
        {
            logParam = settingInfoParam;
            string tttagKey =  CommonUrl.getURL(null,settingInfoParam);;
            //templateJSON
            SysSettingInfo param = Json.Deserialize<SysSettingInfo>(settingInfoParam);
            try
            {
                SysSettingInfo settingInfo = YZ.GetDatabase(tttagKey).Get<SysSettingInfo>(param);
                if (settingInfo != null)
                {
                    return JsonConvert.SerializeObject(settingInfo);//Serialize 序列化
                }
                else
                {
                    return CommonLog.MsgErrorInfo("失败,请检查标识");
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：单个全局" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("内部错误");
            }
        }
        /// <summary>
        /// 所有全局设置 11-10
        /// </summary>
        /// <param name="getGlobalsParam"></param>
        /// <returns></returns>
        public string GetGlobals(string getGlobalsParam)
        {
            logParam = getGlobalsParam;
                HashParam param = Json.Deserialize<HashParam>(getGlobalsParam);
            string tttagKey =  CommonUrl.getURL(param,getGlobalsParam);;
            //参数可全空
            //HashParam param = Json.Deserialize<HashParam>(getGlobalsParam);//PageParam是个坑 9-6
            try
            {
                string str = param.GetString("ConfigProducts");
                string Ids = "";
                Hashtable hash = new Hashtable();
                if (!string.IsNullOrEmpty(str))
                {
                    Ids = str.ToLower().Replace("diamond", "1").Replace("parcel", "2").Replace("ring", "3").Replace("gems", "4").Replace("emerald", "5").Replace("gold", "6").Replace("inlaysettings", "7").Replace("|", ",");
                    Ids = Ids.TrimEnd(',');
                }
                hash.Add("Ids", Ids.Split(','));
                IList<SysSettingInfo> _settingInfo = YZ.GetDatabase(tttagKey).QueryForList<SysSettingInfo>("Syssetting.GetList", hash);//IList 11-10
                if (_settingInfo != null && _settingInfo.Count > 0)
                {
                    return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(_settingInfo));
                }
                else
                {
                    return CommonLog.MsgErrorInfo("没有任何记录");//空
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：所有全局设置" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("程序错误");
            }
        }
        /// <summary>
        /// 返回更新日志 9-29
        /// </summary>
        /// <returns></returns>
        public string UpdateLog(string param)
        {
            return AllPublic.UpdateLog(param);
        }
        /// <summary>
        /// 更新本地报价XML 10-9
        /// </summary>
        /// <returns></returns>
        public string UpdateRapXml(string param)
        {
            logParam = param;
            string tttagKey =  CommonUrl.getURL(null,param);;
            //templateJSON
            XmlDocument xmldoc = new XmlDocument();
            string path = AppDomain.CurrentDomain.BaseDirectory + "App_Data\\diamond_all_price.xml";//本地xml路径
            //查询查宝网xml
            XmlDocument xmldoc_checkgems = new XmlDocument();
            try
            {
                //放配置文件中，到时xml改路径不用改程序，要求xml一样就行
                var url = ConfigurationManager.AppSettings["PricexmlUrlByCheckgems"]; //http://www.checkgems.com/calc/pricelist?code=web
                xmldoc_checkgems.Load(url);
                xmldoc.Load(path);
                XmlNodeList xnlPrice = xmldoc_checkgems.SelectNodes("/items/item");
                //接口报价表内容是否正确
                if (xnlPrice.Count > 0)
                {
                    var version = xmldoc_checkgems.SelectSingleNode("/items/version").InnerText;  //查宝网  //xmldoc_checkgems.InnerText 也可获取
                    var version2 = xmldoc.SelectSingleNode("/items/version").InnerText;  //本地
                    if (version != version2) //不一样 更新文件
                    {
                        using (FileStream fs = new FileStream(path, FileMode.Create))
                        {
                            StreamWriter sw = new StreamWriter(fs, Encoding.Default);
                            sw.Write(xmldoc_checkgems.InnerXml);
                            sw.Close();
                        }
                        xmldoc.Load(path); //重新载入
                        return CommonLog.MsgSuccessInfo("更新成功");
                    }
                    else
                    {
                        return CommonLog.MsgSuccessInfo("已是最新");
                    }
                }
                else
                {
                    return CommonLog.MsgErrorInfo("接口报价表内容错误，正确示例<item key='' value=''/>");
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：更新本地报价XML" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("更新报价表失败");
            }
        }
        /// <summary>
        /// app 专用
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetAppIndexInfo(string strParam)
        {
            logParam = strParam;
                HashParam param = Json.Deserialize<HashParam>(strParam);
            string tttagKey =  CommonUrl.getURL(param,strParam);;
            try
            {
                string Globals = "";
                #region GetGlobals
                {
                    string str = param.GetString("ConfigProducts");
                    string Ids = "";
                    Hashtable hash = new Hashtable();
                    if (!string.IsNullOrEmpty(str))
                    {
                        Ids = str.ToLower().Replace("diamond", "1").Replace("parcel", "2").Replace("ring", "3").Replace("gems", "4").Replace("emerald", "5").Replace("gold", "6").Replace("inlaysettings", "7").Replace("|", ",");
                        Ids = Ids.TrimEnd(',');
                    }
                    hash.Add("Ids", Ids.Split(','));
                    IList<SysSettingInfo> _settingInfo = YZ.GetDatabase(tttagKey).QueryForList<SysSettingInfo>("Syssetting.GetList", hash);//IList 11-10
                    if (_settingInfo != null && _settingInfo.Count > 0)
                    {
                        Globals = JsonConvert.SerializeObject(_settingInfo);
                    }
                    else
                    {
                        Globals = CommonLog.MsgErrorInfo("没有任何记录");//空
                    }
                }
                #endregion
                string Notices = "";
                #region GetNotices
                {
                    PageList<NoticeInfo> _noticesInfo = YZ.GetDatabase(tttagKey).QueryForList<NoticeInfo>("Notice.GetList", param, Convert.ToInt32(param.GetInt("PageSize")), Convert.ToInt32(param.GetInt("PageIndex")));//ToInt32 9-6
                    if (_noticesInfo != null && _noticesInfo.Data.Count > 0)
                    {
                        Notices = JsonConvert.SerializeObject(_noticesInfo);
                    }
                    else
                    {
                        //空
                        Notices = CommonLog.MsgErrorInfo("没有任何记录");
                    }
                }
                #endregion
                string msgInfo_ = "{\"msgcode\":true,\"GetGlobals\":#Globals,\"GetNotices\":#Notices}";
                return msgInfo_.Replace("#Globals", Globals).Replace("#Notices", Notices);
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：所有全局设置" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("程序错误");
            }
        }
        #endregion
        #region  流上传
        /// <summary>
        /// WCF服务端上传文件File到数据中心
        /// </summary>
        /// <returns></returns>
        public UpFileResult OldUploadFile(FileUploadMessage request)
        {
            UpFileResult result = new UpFileResult();
            string tttagKey = "";
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                    tttagKey = request.key;
                }
                //上传
                string guid = Guid.NewGuid().ToString();
                Dictionary<string, string> param = new Dictionary<string, string>();
                string stateid = "1"; //上传模式（0覆盖 1追加）
                string secondSn = "";
                if (HttpContext.Current.Request.Url.Query.Contains("?addType=1") || HttpContext.Current.Request.Url.Query.Contains("?addType=0"))
                {
                    string paramStr = HttpContext.Current.Request.Url.Query.Replace("?", "");
                    string[] paramStrSplit = paramStr.Split('&');
                    stateid = paramStrSplit[0].Split('=')[1];
                    secondSn = paramStrSplit[1].Split('=')[1];
                    param["SecondSN"] = secondSn;
                    secondSn = "&SecondSN=" + secondSn;
                }
                else
                {
                    if (HttpRuntime.Cache.Get("StateId" + tttagKey) != null)
                    {
                        stateid = HttpRuntime.Cache.Get("StateId" + tttagKey).ToString();
                    }
                }
                param["is_append"] = stateid.ToString(); //是否已追加的方式导入，如果为0则清空以前的库存，默认1
                var RequestUrl = GlobalConfig.TransmissionUpStockURL + "files/?is_append=" + stateid.ToString();
                //排序参数
                StringBuilder sbStr = MyHttpRequest.ShotDic(param);
                int totalSeconds;
                string signStr;
                //签名
                MyHttpRequest.SignByParams(guid, sbStr.ToString(), tttagKey, out totalSeconds, out signStr);
                RequestInfo ri = new RequestInfo()
                {
                    RequestJson = JsonConvert.SerializeObject(param),
                    RequestUrl = GlobalConfig.TransmissionUpStockURL + "files/?is_append=" + stateid.ToString() + secondSn  //secondSn,有可能为二级提交
                };
                //发送带签名的参数
                var httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Connection.Add("keep-alive");//保持长连接
                using (var content = new MultipartFormDataContent())
                {
                    var fileContent = new StreamContent(request.FileData);
                    fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = request.FileName, Name = "file_data" };
                    content.Add(fileContent);
                    content.Headers.Add("UUID", guid);
                    content.Headers.Add("Auth", signStr);
                    content.Headers.Add("Time", totalSeconds.ToString());
                    //提交数据中心
                    var responseJson = httpClient.PostAsync(RequestUrl, content)
                     .Result.Content.ReadAsStringAsync().Result;
                    result.Message = @responseJson;//上传结果
                    if (@responseJson.Contains("result\":\"true") || JsonConvert.DeserializeObject<HashParam>(@responseJson).GetString("result").ToLower() == "true")
                    {
                        result.IsSuccess = true;
                    }
                    else
                        result.IsSuccess = false;
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心" + ex.StackTrace + "参数:" + logParam);
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                Logger.Warn(typeof(Distribution), "服务端上传到数据中心失败");
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心(多级接收：一级客户端，二级服务)  2017-02-06
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //一定先区分是一级上传 还是二级上传 通过SecondSN
                //getUploadState 
                var partUrl = "";
                if (request.FileName.LastIndexOf('?') > 0)
                {
                    partUrl = request.FileName.Substring(request.FileName.LastIndexOf('?'));//报错
                    request.FileName = request.FileName.Replace(partUrl, "");
                }
                else
                {
                    result.Message = "参数错误,合格参数示例/Team/UploadFile?addType=1";
                    return result;
                }
                //上传
                partUrl = partUrl.Replace("addType", "is_append"); //以前用addType这个参数
                Dictionary<string, string> dict = MyHttpRequest.GetParams(partUrl); //提取字符串参数
                string stateid = "1"; //上传模式（0覆盖 1追加）
                if (dict.ContainsKey("is_append")) //首先取字典
                {
                    stateid = dict["is_append"].ToString();
                }
                else if (HttpRuntime.Cache.Get("StateId" + request.key) != null) //如果字典中没有则取缓存
                {
                    stateid = HttpRuntime.Cache.Get("StateId" + request.key).ToString();
                    dict.Add("is_append", stateid); //加上
                    //处理url
                    if (dict.Count > 0)            //有参数
                        partUrl += "&is_append=" + stateid;
                    else                          //无参数
                        partUrl = "?is_append=" + stateid;
                }
                var RequestUrl = GlobalConfig.TransmissionUpStockURL + "files/" + partUrl;
                //排序参数
                StringBuilder sbStr = MyHttpRequest.ShotDic(dict);
                result = UpLoadPart2(request, RequestUrl, sbStr.ToString());
                #region 日志
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                    //获取URL和登录用户ID
                    if (!string.IsNullOrEmpty(request.url))
                    {
                        string url = request.url.Split('~')[0];
                        string userid = request.url.Split('~')[1];
                        string ActiveIP = request.url.Split('~')[2];
                        UserLog userLog = new UserLog();
                        userLog.option = "上传文件操作" + (stateid == "0" ? "【覆盖】" : "【追加】") + result;
                        MyHttpRequest.GetAKByKey(request.key, out string AccessKey, out string AccessSecret);
                        userLog.httpURL = url;
                        userLog.loginUserID = userid;
                        userLog.tagKey = request.key;
                        userLog.ActiveIP = ActiveIP;
                        userLog.TransmissionAccessKey = AccessKey;
                        userLog.TransmissionAccessSecret = AccessSecret;
                        userLog.optionTime = DateTime.Now;

                        CommonLog.SendMQMsg(tttagKey, "上传文件成功" + JsonConvert.SerializeObject(userLog));

                    }
                }
                else
                {
                    result.Message = "获取key失败，key为空";
                    result.IsSuccess = false;
                    CommonLog.SendMQMsg(tttagKey, "异常信息：上传文件 数据中心返回" + JsonConvert.SerializeObject(result));
                    return result;
                }
                #endregion
            }
            catch (Exception ex)
            {
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心(多级接收：一级客户端，二级服务)" + ex.StackTrace + "参数:" + logParam);
            }
            return result;
        }
        private UpFileResult UpLoadPart2(FileUploadMessage request, string RequestUrl, string sbStr)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //处理fileName
                string partUrl = "";
                if (request.FileName.LastIndexOf('?') > 0)
                {
                    partUrl = request.FileName.Substring(request.FileName.LastIndexOf('?'));//得到剩下的url
                    request.FileName = request.FileName.Replace(partUrl, "");
                }
                if (sbStr == "" && partUrl != "") //彩宝，统包，成品过来
                {
                    Dictionary<string, string> dict = MyHttpRequest.GetParams(partUrl);
                    sbStr = MyHttpRequest.ShotDic(dict).ToString();
                }
                int totalSeconds;
                string signStr;
                //签名
                string guid = Guid.NewGuid().ToString();
                MyHttpRequest.SignByParams(guid, sbStr, request.key, out totalSeconds, out signStr);
                //发送带签名的参数
                var httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Connection.Add("keep-alive");//保持长连接
                using (var content = new MultipartFormDataContent())
                {
                    var fileContent = new StreamContent(request.FileData);
                    fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = request.FileName, Name = "file_data" };
                    content.Add(fileContent);
                    content.Headers.Add("UUID", guid);
                    content.Headers.Add("Auth", signStr);
                    content.Headers.Add("Time", totalSeconds.ToString());
                    //提交数据中心
                    var responseJson = httpClient.PostAsync(RequestUrl + partUrl, content)
                     .Result.Content.ReadAsStringAsync().Result;
                    result.Message = @responseJson;//上传结果
                    result.IsSuccess = @responseJson.Contains("result\": true");
                }
                return result;
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：" + ex.StackTrace + "参数:" + logParam);
                throw;
            }
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心 (成品货表)
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadInlayFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                }
                result = UpLoadPart2(request, GlobalConfig.TransmissionInlaysImportUrl, "");
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心 (成品货表)" + ex.StackTrace + "参数:" + logParam);
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                Logger.Warn(typeof(Distribution), "服务端上传到数据中心失败");
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心 (彩宝货表)
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadGemsFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                }
                result = UpLoadPart2(request, GlobalConfig.TransmissionGemsImportUrl, "");
            }
            catch (Exception ex)
            {
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息： WCF服务端上传文件File到数据中心 (彩宝货表)" + ex.StackTrace + "参数:" + logParam);
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心 (统包货表)
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadParcelsFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            Logger.Info(typeof(Distribution), "UploadParcelsFile:" + request.FileName);
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                }
                result = UpLoadPart2(request, GlobalConfig.TransmissionParcelsImportUrl, "");
            }
            catch (Exception ex)
            {
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心 (统包货表)1" + ex.StackTrace + "参数:" + logParam);
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心 (统包货表)
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadEmeraldsFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                }
                result = UpLoadPart2(request, GlobalConfig.TransmissionEmeraldsImportUrl, "");
            }
            catch (Exception ex)
            {
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心 (统包货表)2" + ex.StackTrace + "参数:" + logParam);
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心 (统包货表)
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadPrimeGoldsFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                }
                result = UpLoadPart2(request, GlobalConfig.TransmissionPrimeGoldsImportUrl, "");
            }
            catch (Exception ex)
            {
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心 (统包货表)3" + ex.StackTrace + "参数:" + logParam);
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传文件File到数据中心 (统包货表)
        /// </summary>
        /// <returns></returns>
        public UpFileResult UploadInlaySettingsFile(FileUploadMessage request)
        {
            string tttagKey = request.key;
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(request.key))
                {
                    GlobalConfig.reLoadKey(request.key);
                }
                result = UpLoadPart2(request, GlobalConfig.TransmissionInlaySettingsImportUrl, "");
            }
            catch (Exception ex)
            {
                result.Message = "服务端上传到数据中心失败";
                result.IsSuccess = false;
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传文件File到数据中心 (统包货表)3" + ex.StackTrace + "参数:" + logParam);
            }
            return result;
        }
        /// <summary>
        /// WCF服务端上传图片Image到数据中心
        /// </summary>
        /// <param name="imageParam"></param>
        /// <returns></returns>
        public UpFileResult UploadImage(FileUploadMessage imageParam)
        {
            string tttagKey = imageParam.key;
            //#msg 和"#msg" 
            UpFileResult result = new UpFileResult();
            try
            {
                //获取Key
                if (!string.IsNullOrEmpty(imageParam.key))
                {
                    GlobalConfig.reLoadKey(imageParam.key);
                }
                var type = imageParam.FileName.Split('|')[1];
                var imageName = imageParam.FileName.Split('|')[0];
                var RequestUrl = string.Format(GlobalConfig.TransmissionImageUploadUrl, type, 0);
                //上传
                string guid = Guid.NewGuid().ToString();
                int totalSeconds;
                string signStr;
                //签名
                MyHttpRequest.SignByParams(guid, "", imageParam.key, out totalSeconds, out signStr);
                RequestInfo ri = new RequestInfo()
                {
                    RequestUrl = RequestUrl // secondSn,有可能为二级提交
                };
                //发送带签名的参数
                var httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Connection.Add("keep-alive");//保持长连接
                using (var content = new MultipartFormDataContent())
                {
                    var fileContent = new StreamContent(imageParam.FileData);
                    fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = imageName, Name = "file_data" };
                    content.Add(fileContent);
                    content.Headers.Add("UUID", guid);
                    content.Headers.Add("Auth", signStr);
                    content.Headers.Add("Time", totalSeconds.ToString());
                    //提交数据中心
                    var responseJson = httpClient.PostAsync(RequestUrl, content)
                     .Result.Content.ReadAsStringAsync().Result;
                    result.Message = @responseJson;//上传结果
                    result.IsSuccess = JsonConvert.DeserializeObject<HashParam>(@responseJson).GetBool("result");
                }
                return result;
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传图片Image到数据中心1" + ex.StackTrace + "参数:" + logParam);
                result.Message = "上传出错:程序错误";
                result.IsSuccess = false;
                return result;
            }
        }
        /// <summary>
        /// WCF服务端上传图片Image到数据中心
        /// </summary>
        /// <param name="imageParam"></param>
        /// <returns></returns>
        public UpFileResult UploadImage(ImageUploadMessage imageParam)
        {
            string tttagKey = imageParam.key;
            //#msg 和"#msg"
            UpFileResult result = new UpFileResult();
            if (imageParam.ImageDatas.Length == 0)
            {
                result.Message = "{\"msg\": \"noImgUpload\", \"successes\": [], \"result\": false, \"failures\": []}";//上传结果
                result.IsSuccess = false;
            }
            else
            {
                try
                {
                    //获取Key
                    if (!string.IsNullOrEmpty(imageParam.key))
                    {
                        GlobalConfig.reLoadKey(imageParam.key);
                    }
                    var type = imageParam.TypeName;
                    var RequestUrl = "";
                    if (imageParam.type == "img")
                        RequestUrl = string.Format(GlobalConfig.TransmissionImageUploadUrl, type, "");
                    else if (imageParam.type == "video")
                        RequestUrl = string.Format(GlobalConfig.TransmissionVideoUploadUrl, type, "");
                    //上传
                    string guid = Guid.NewGuid().ToString();
                    int totalSeconds;
                    string signStr;
                    //签名
                    MyHttpRequest.SignByParams(guid, "", imageParam.key, out totalSeconds, out signStr);
                    RequestInfo ri = new RequestInfo()
                    {
                        RequestUrl = RequestUrl // secondSn,有可能为二级提交
                    };
                    //发送带签名的参数
                    var httpClient = new HttpClient();
                    httpClient.DefaultRequestHeaders.Connection.Add("keep-alive");//保持长连接
                    using (var content = new MultipartFormDataContent())
                    {
                        for (int i = 0; i < imageParam.ImageDatas.Count(); i++)
                        {
                            //var fileContent = new StreamContent(imageParam.ImageDatas[i].ImageData);
                            var fileContent = new StreamContent(new MemoryStream(imageParam.ImageDatas[i].ImageData));
                            fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = FormatFileName(imageParam.ImageDatas[i].FileName), Name = "file_data" };
                            content.Add(fileContent);
                        }
                        content.Headers.Add("UUID", guid);
                        content.Headers.Add("Auth", signStr);
                        content.Headers.Add("Time", totalSeconds.ToString());
                        //提交数据中心
                        var responseJson = httpClient.PostAsync(RequestUrl, content)
                         .Result.Content.ReadAsStringAsync().Result;
                        result.Message = @responseJson;//上传结果
                        result.IsSuccess = JsonConvert.DeserializeObject<HashParam>(@responseJson).GetBool("result");
                    }
                }
                catch (Exception ex)
                {
                    CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                    CommonLog.SendMQMsg(tttagKey, "异常信息：WCF服务端上传图片Image到数据中心2" + ex.StackTrace + "参数:" + logParam);
                    result.Message = "上传出错:程序错误";
                    result.IsSuccess = false;
                    return result;
                }
            }
            return result;
        }
        public string FormatFileName(string name)
        {
            if (name.LastIndexOf(".") > -1)
            {
                name = DateTime.Now.Ticks.ToString() + (name.Substring(name.LastIndexOf("."), name.Length - name.LastIndexOf(".")));
            }
            return name;
        }
        #endregion
        #region 用户活跃度
        /// <summary>
        /// 活跃时间
        /// </summary>
        /// <returns></returns>
        public string GetActiveTime(string activeTimeParam)
        {
            logParam = activeTimeParam;
            HashParam param = Json.Deserialize<HashParam>(activeTimeParam); //Deserialize 反序列化
            string tttagKey =  CommonUrl.getURL(param,activeTimeParam);;
            IList<HashResult> days = YZ.GetDatabase(tttagKey).QueryForList<HashResult>("Address.GetDay", param);//2016-11-17 10:07:13
            IList<HashResult> months = YZ.GetDatabase(tttagKey).QueryForList<HashResult>("Address.GetMonth", param);
            var activeResult = new Dictionary<string, IList<HashResult>>();
            activeResult.Add("months", months);
            activeResult.Add("days", days);
            var str = JsonConvert.SerializeObject(activeResult);
            return str;
        }
        /// <summary>
        /// 活跃地区
        /// </summary>
        /// <returns></returns>
        public string GetActiveArea(string activeAreaParam)
        {
            logParam = activeAreaParam;
            HashParam param = Json.Deserialize<HashParam>(activeAreaParam); //Deserialize 反序列化
            string tttagKey =  CommonUrl.getURL(param,activeAreaParam);;
            IList ips = YZ.GetDatabase(tttagKey).QueryForList("Address.GetArea", param);
            Dictionary<string, int> addrsInfo = new Dictionary<string, int>();
            foreach (var ip in ips)
            {
                if (ip != null && ip.ToString().Length > 6) //min 7
                {
                    var addr = getAddrByIP(ip.ToString());
                    var addrs = addr.Split('\t');
                    addr = addrs[2]; //中国广东广州(取广州) 
                    if (addr == "")
                    {
                        addr = addrs[1]; //中国香港(取香港) 美国美国(取美国)
                    }
                    addr = addr == "resultOffSet too small" ? "未知" : addr == "共享地址" ? "未知" : addr == "CLOUDFLARE" ? "未知" : addr;
                    if (addrsInfo.ContainsKey(addr))
                    {
                        addrsInfo[addr]++;
                    }
                    else
                    {
                        addrsInfo.Add(addr, 1);
                    }
                }
            }
            addrsInfo = addrsInfo.OrderByDescending(t => t.Value).ToDictionary(a => a.Key, b => b.Value);
            return JsonConvert.SerializeObject(addrsInfo);
        }
        /// <summary>
        /// 根据活跃IP得到活跃地区
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public string getAddrByIP(string ip)
        {
            //DataHandler ips = new DataHandler(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "au/ikvm_data\\db.dat"));
            //var ipStr = ips.findGeography(ip);
            //return ipStr;
            return ip;
        }
        #endregion
        #region 各种统计相关
        /// <summary>
        /// 统计每年每月的订单 9-22
        /// </summary>
        /// <param name="orderNumberParam"></param>
        /// <returns></returns>
        public string OrderMonth(string orderMonthParam)
        {
            return CWholesalers.OrderMonth(orderMonthParam);
        }
        /// <summary>
        /// 订单个数统计 、各订单状态卖出RMB和买入美金统计 9-22
        /// </summary>
        /// <returns></returns>
        public string OrderNumber(string orderNumberParam)
        {
            return CWholesalers.OrderNumber(orderNumberParam);
        }
        /// <summary>
        /// 结算订单状态统计 11-2
        /// </summary>
        /// <param name="orderNumberParam"></param>
        /// <returns></returns>
        public string SettleOrderNumber(string settleOrderNumberParam)
        {
            return CWholesalers.SettleOrderNumber(settleOrderNumberParam);
        }
        /// <summary>
        /// 结算订单支付状态统计 11-2
        /// </summary>
        /// <param name="orderPaymentStatusNumberParam"></param>
        /// <returns></returns>
        public string SettleOrderPaymentStatusNumber(string settleOrderPaymentStatusNumberParam)
        {
            return CWholesalers.SettleOrderPaymentStatusNumber(settleOrderPaymentStatusNumberParam);
        }
        /// <summary>
        /// 订单支付状态统计
        /// </summary>
        /// <param name="orderNumberParam"></param>
        /// <returns></returns>
        public string OrderPaymentStatusNumber(string orderPaymentStatusNumberParam)
        {
            return CWholesalers.OrderPaymentStatusNumber(orderPaymentStatusNumberParam);
        }
        //柱状图 业务每月销售额 9-23 test
        public string TestHigh(string testParam)
        {
            return CWholesalers.TestHigh(testParam);
        }
        /// <summary>
        /// 客户个数统计
        /// </summary>
        /// <returns></returns>
        public string CustomerNumber(string customerNumberParam)
        {
            return CWholesalers.CustomerNumber(customerNumberParam);
        }
        /// <summary>
        /// 充值个数统计
        /// </summary>
        /// <returns></returns>
        public string ChargeNumber(string chargeNumberParam)
        {
            return CWholesalers.ChargeNumber(chargeNumberParam);
        }
        /// <summary>
        /// 购物车个数统计
        /// </summary>
        /// <param name="chargeNumberParam"></param>
        /// <returns></returns>
        public string CartNumber(string cartNumberParam)
        {
            return CWholesalers.CartNumber(cartNumberParam);
        }
        /// <summary>
        /// 订单周报表 2017-02-18
        /// </summary>
        /// <returns></returns>
        public string OrderReport(string reportParam)
        {
            return CWholesalers.OrderReport(reportParam);
        }
        //得到单周的数据
        private static HashParam GetInfoByWeek(PageParamOfOrder param1, string key, ref decimal lastWeekUSD, ref decimal lastWeekRate)
        {
            //RestUSD 周剩余美金
            // WeekPurchaseExchange 周采购汇率  
            // WeekAvgExchange 周平均汇率 
            // WeekExUSD 周兑换美金
            // WeekNum 周美金结算订单数
            // WeekUSD 周总美金
            // WeekRMB 周总人民币
            // WeekExpense 周取货费用
            decimal? RestUSD = 0, WeekUSD = 0, WeekRMB = 0, WeekAvgExchange = 0, WeekPurchaseExchange = 0, WeekNum = 0, WeekExpense = 0;
            decimal? totalUSD2 = 0,//周应支付金额
                    totalUSD3 = 0;//周总已兑换美金
            HashParam param2 = new HashParam();
            //本周全部订单
            #region
            IList<OrderInfo> _ordersInfo = YZ.GetDatabase(key).QueryForList<OrderInfo>("Order.GetOrders", param1);//本周
            if (_ordersInfo != null && _ordersInfo.Count > 0)
            {
                foreach (var item in _ordersInfo)
                {
                    //定货
                    if (item.SupplierCode.ToUpper() != key)
                    {
                        //美金结算
                        if (item.CurType == 2)
                        {
                            WeekUSD += item.PriceUSD;//周总美金
                            WeekNum++;//周美金结算订单数
                        }
                        else
                        {
                            WeekRMB += item.PurchaseRMB;//周总人民币
                        }
                    }
                    else
                    {
                        //现货                        
                    }
                }
                //WeekExpense = WeekUSD * Convert.ToDecimal(0.004);//周取货费用
                WeekExpense = WeekUSD * Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["BaseFreight"]);//周取货费用  2017-02-23              
            }
            #endregion
            //本周兑换记录
            #region
            IList<ExchangeResult> _exchangeInfo = YZ.GetDatabase(key).QueryForList<ExchangeResult>("Exchange.GetExchanges", param1);//本周兑换记录
            if (_exchangeInfo != null && _exchangeInfo.Count > 0)
            {
                foreach (var item in _exchangeInfo)
                {
                    totalUSD2 += item.Exchange * item.Amount;//总应支付金额
                    totalUSD3 += item.Amount;//总已兑换美金
                }
                WeekAvgExchange = totalUSD2 / totalUSD3;//周平均汇率
            }
            #endregion
            //本周订单买入$ 和 个数
            #region
            param2["WeekUSD"] = WeekUSD;
            param2["WeekNum"] = WeekNum;
            param2["WeekExpense"] = WeekExpense;
            param2["WeekAvgExchange"] = WeekAvgExchange;
            param2["WeekExUSD"] = totalUSD3;//周兑换美金
            param2["EArrivalTime"] = param1.EArrivalTime.Value.ToShortDateString();
            param2["SArrivalTime"] = param1.SArrivalTime.Value.ToShortDateString();
            //本周剩余美金 = （本周兑换美金 + 上周剩余美金） -（本周取货花费 + 本周取货产生的带货费用）
            //param2["RestUSD"] = (totalUSD3 + 0) - WeekUSD - WeekExpense;//周剩余美金
            RestUSD = (totalUSD3 + lastWeekUSD) - (WeekUSD + WeekExpense);//（上周剩余+本周兑换）-本周开销
            param2["RestUSD"] = RestUSD;//周剩余美金
            //本周新汇率 = ( (上周剩余美金 * 上周平均汇率) + (本周兑换美金 * 本周平均汇率) ) / (上周剩余美金 + 本周兑换美金)
            //WeekPurchaseExchange = ((0 * 0) + (totalUSD3 * WeekAvgExchange)) / (0 + totalUSD3);//周采购汇率 -首次
            if (lastWeekUSD + totalUSD3 > 0)
            {
                WeekPurchaseExchange = (Convert.ToDecimal(lastWeekUSD * lastWeekRate) + (totalUSD3 * WeekAvgExchange)) / (lastWeekUSD + totalUSD3);//周采购汇率
            }
            else
            {
                WeekPurchaseExchange = 0;
            }
            param2["WeekPurchaseExchange"] = WeekPurchaseExchange;//周采购汇率
            #endregion
            if (RestUSD.Value < 0)
            {
                lastWeekUSD = 0; //存储给下次使用
            }
            else
            {
                lastWeekUSD = RestUSD.Value; //存储给下次使用
            }
            lastWeekRate = WeekPurchaseExchange.Value;//存储给下次使用
            return param2;
        }
        //某日期得到以前的数据
        private static HashParam GetHistoryInfo(PageParamOfOrder param1, string key)
        {
            decimal? RestUSD = 0, WeekUSD = 0, WeekRMB = 0, WeekAvgExchange = 0, WeekNum = 0, WeekExpense = 0;
            decimal? totalUSD2 = 0,//周应支付金额
                    totalUSD3 = 0;//周总已兑换美金
            HashParam param2 = new HashParam();
            //某日期以前全部订单
            #region
            IList<OrderInfo> _ordersInfo = YZ.GetDatabase(key).QueryForList<OrderInfo>("Order.GetOrders", param1);//本周
            if (_ordersInfo != null && _ordersInfo.Count > 0)
            {
                foreach (var item in _ordersInfo)
                {
                    //定货
                    if (item.SupplierCode.ToUpper() != key)
                    {
                        //美金结算
                        if (item.CurType == 2)
                        {
                            WeekUSD += item.PriceUSD;//周总美金
                            WeekNum++;//周美金结算订单数
                        }
                        else
                        {
                            WeekRMB += item.PurchaseRMB;//周总人民币
                        }
                    }
                    else
                    {
                        //现货                        
                    }
                }
                WeekExpense = WeekUSD * Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["BaseFreight"]);//周取货费用
            }
            #endregion
            //本周兑换记录
            #region
            IList<ExchangeResult> _exchangeInfo = YZ.GetDatabase(key).QueryForList<ExchangeResult>("Exchange.GetExchanges", param1);//本周兑换记录
            if (_exchangeInfo != null && _exchangeInfo.Count > 0)
            {
                foreach (var item in _exchangeInfo)
                {
                    totalUSD2 += item.Exchange * item.Amount;//总应支付金额
                    totalUSD3 += item.Amount;//总已兑换美金
                }
                WeekAvgExchange = totalUSD2 / totalUSD3;//周平均汇率
            }
            #endregion
            RestUSD = (totalUSD3) - (WeekUSD + WeekExpense);
            if (RestUSD.Value < 0)
            {
                param2["RestUSD"] = 0;//负数为剩余0
            }
            else
            {
                param2["RestUSD"] = RestUSD.Value;
            }
            param2["WeekPurchaseExchange"] = WeekAvgExchange;
            return param2;
        }
        #endregion
        #region  供应商数据过滤
        /// <summary>
        /// 中心供应商列表 2017-03-08
        /// </summary>
        /// <returns></returns>
        public string GetCenterSuppliers(string param)
        {
            var aaa = AllPublic.ReturnSupplier(param);
            return aaa;
        }
        /// <summary>
        /// 单个远程供应商 12-27
        /// </summary>
        /// <param name="getSupplierParam"></param>
        /// <returns></returns>
        public string GetCenterSupplier(string getCenterSupplierParam)
        {
            return CWholesalers.GetCenterSupplier(getCenterSupplierParam);
        }
        /// <summary>
        /// 得到单个供应商设置
        /// </summary>
        /// <returns></returns>
        public string GetSupplierSet(string getParcelParam)
        {
            return CWholesalers.GetSupplierSet(getParcelParam);
        }
        /// <summary>
        /// 得到多个供应商设置列表
        /// </summary>
        /// <returns></returns>
        public string GetSuppliersSet(string param)
        {
            return CWholesalers.GetSuppliersSet(param);
        }
        public int DelSupplier(string setSupplierParam)
        {
            logParam = setSupplierParam;
            string tttagKey = CommonUrl.getURL(null,setSupplierParam, "删除供应商");
            Hashtable param = MyHashtable.NewHashtable(Json.Deserialize<Hashtable>(setSupplierParam));
            IList<SupplierInfo> list = YZ.GetDatabase(tttagKey).QueryForList<SupplierInfo>("Supplier.GetSupplierList", param);
            if (list != null && list.Count > 0)
            {
                HttpContext.Current.Cache.Remove("Cache:Suppliers" + tttagKey + list[0].SupplierCode + list[0].SupplierType);
            }
            var supplierAttach = JsonConvert.DeserializeObject<SupplierAttach>(setSupplierParam);
            var a = YZ.GetDatabase(tttagKey).Delete("Supplier.BatchDelete", supplierAttach);
            return a;
        }
        /// <summary>
        /// 加入或移除黑名单
        /// //Set供应商(单个)，supplierCode名字，category类别（stocks，inlays，parcels），state 状态( false, #不在黑名单中| true, #在黑名单中)
        /// </summary>
        /// <param name="modParcelParam"></param>
        /// <returns></returns>
        public string SetSupplier(string setSupplierParam)
        {
            return CWholesalers.SetSupplier(setSupplierParam);
        }
        /// <summary>
        /// 查询非裸钻日志
        /// </summary>
        /// <param name="strParam"></param>
        public void ProductSearch(string strParam)
        {
            CWholesalers.ProductSearch(strParam);
        }
        /// <summary>
        /// 加入或移除白名单
        /// </summary>
        /// <param name="setSupplierParam"></param>
        /// <returns></returns>
        public string SetSupplierWhite(string setSupplierParam)
        {
            return CWholesalers.SetSupplierWhite(setSupplierParam);
        }
        /// <summary>
        /// //Set供应商(多个)，blacklist,黑名单list， stocks钻石，parcels统包，inlays成品 ....，["abc", "def"]指（钻石）拉黑：abc，及def两家供应商
        /// </summary>
        /// <param name="modParcelParam"></param>
        /// <returns></returns>
        public string SetSuppliers(string setSupplierParam)
        {
            return CWholesalers.SetSuppliers(setSupplierParam);
        }
        #endregion
        #region  兑换记录Exchange
        /// <summary>
        /// 兑换列表 01-03
        /// </summary>
        /// <param name="getExchangesParam"></param>
        /// <returns></returns>
        public string GetExchanges(string getExchangesParam)
        {
            return CWholesalers.GetExchanges(getExchangesParam);
        }
        /// <summary>
        /// 最近的采购汇率
        /// </summary>
        /// <returns></returns>
        public string ComputePurchaseExchange(string getExchangeListParam)
        {
            return CWholesalers.ComputePurchaseExchange(getExchangeListParam);
        }
        /// <summary>
        /// 修改采购汇率 9-6
        /// </summary>
        /// <param name="arrivalOrdersParam"></param>
        /// <returns></returns>
        public string ExchangeOrders(string exchangeOrdersParam)
        {
            return CWholesalers.ExchangeOrders(exchangeOrdersParam);
        }
        #endregion
        #region 供应商相关
        /// <summary>
        /// 供应商联系方式 11-5
        /// </summary>
        /// <param name="contactParam"></param>
        /// <returns></returns>
        public string ContactSupplier(string contactParam)
        {
            return CWholesalers.ContactSupplier(contactParam);
        }
        /// <summary>
        /// 所有供应商 9-6
        /// </summary>
        /// <param name="getSuppliersParam"></param>
        /// <returns></returns>
        public string GetSupplierList(string getSupplierListParam)
        {
            return CWholesalers.GetSupplierList(getSupplierListParam);
        }
        /// <summary>
        /// 添加供应商 -- 含事务
        /// </summary>
        /// <param name="addCustomerParam"></param>
        /// <returns></returns>
        public string AddSupplier(string addSupplierParam)
        {
            return CWholesalers.AddSupplier(addSupplierParam);
        }
        /// <summary>
        /// 修改供应商
        /// </summary>
        /// <param name="editCustomerParam"></param>
        /// <returns></returns>
        public string EditSupplier(string editSupplierParam)
        {
            return CWholesalers.EditSupplier(editSupplierParam);
        }
        /// <summary>
        /// 供应商列表------ 纯粹读数据 无需 事务
        /// </summary>
        /// <param name="getOrdersParam"></param>
        /// <returns></returns>
        public string GetSuppliers(string getSuppliersParam)
        {
            return CWholesalers.GetSuppliers(getSuppliersParam);
        }
        /// <summary>
        /// 单个供应商信息
        /// </summary>
        /// <param name="customerInfoParam"></param>
        /// <returns></returns>
        public string GetSupplierInfo(string supplierInfoParam)
        {
            return CWholesalers.GetSupplierInfo(supplierInfoParam);
        }
        /// <summary>
        /// 供应商添加简称是否存在
        /// </summary>
        /// <returns></returns>
        public string SupplierRegIsExist(string supplierRegIsExistParam)
        {
            return CWholesalers.SupplierRegIsExist(supplierRegIsExistParam);
        }
        #endregion
        #region 网站对应的联系方式链接（qq,skype）
        //查询
        public string GetLink(string param)
        {
            return AllPublic.GetLink(param);
        }
        //修改网站对应的联系方式链接（qq,skype）
        public string UpdateLink(string param)
        {
            return AllPublic.UpdateLink(param);
        }
        #endregion
        #region Rapnet报价列表
        public string GetRapnetByParam(string param)
        {
            return CWholesalers.GetRapnetByParam(param);
        }
        /// <summary>
        /// 报价表列表
        /// </summary>
        /// <returns></returns>
        public string GetRapnetList(string param)
        {
            return CWholesalers.GetRapnetList(param);
        }
        #endregion
        #region 出货单
        /// <summary>
        /// 查询出货单
        /// </summary>
        /// <param name="CancelGemOrdersParam"></param>
        /// <returns></returns>
        public string GetAllShipNo(string shipOrdersParam)
        {
            return CWholesalers.GetAllShipNo(shipOrdersParam);
        }
        /// <summary>
        /// 查询订单通过出货单号
        /// </summary>
        /// <param name="CancelGemOrdersParam"></param>
        /// <returns></returns>
        public string GetAllOrderByShipNo(string shipOrdersParam)
        {
            return CWholesalers.GetAllOrderByShipNo(shipOrdersParam);
        }
        /// <summary>
        /// 删除出货单里面的订单
        /// </summary>
        /// <param name="CancelGemOrdersParam"></param>
        /// <returns></returns>
        public string DeleteOrderInShipNoByOrderIdsOrShipNo(string shipOrdersParam)
        {
            return CWholesalers.DeleteOrderInShipNoByOrderIdsOrShipNo(shipOrdersParam);
        }
        #endregion 出货单end
        #region 职能角色
        public string GetJobTitleInfo(string param)
        {
            return CWholesalers.GetJobTitleInfo(param);
        }
        /// <summary>
        ///  修改 职能
        /// </summary>
        /// <param name="batchUpdateDiaParam"></param>
        /// <returns></returns>
        public string UpdateJobTitle(string updateParam)
        {
            return CWholesalers.UpdateJobTitle(updateParam);
        }
        /// <summary>
        ///  新增 职能
        /// </summary>
        /// <param name="batchUpdateDiaParam"></param>
        /// <returns></returns>
        public string AddJobTitle(string addParam)
        {
            return CWholesalers.AddJobTitle(addParam);
        }
        #endregion
        #region  菜单列表
        public string GetMenuList(string menuParam)
        {
            return CWholesalers.GetMenuList(menuParam);
        }
        #endregion
        #region 全局日志
        public static SearchParamLog log = new SearchParamLog();
        #endregion 日志
        #region 网站对应的联系方式链接（qq,skype）
        //查询
        public string GetReceivingAddress(string param)
        {
            return CWholesalers.GetReceivingAddress(param);
        }
        //修改网站对应的联系方式链接（qq,skype）
        public string EditReceivingAddress(string param)
        {
            return CWholesalers.EditReceivingAddress(param);
        }
        //修改网站对应的联系方式链接（qq,skype）
        public string AddReceivingAddress(string param)
        {
            return CWholesalers.AddReceivingAddress(param);
        }
        //删除地址
        public string DeleteReceivingAddress(string param)
        {
            return CWholesalers.DeleteReceivingAddress(param);
        }
        #endregion
        /// <summary>
        /// 批量修改裸钻到货时间
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string UpdateArrivalTime(string param)
        {
            return CWholesalers.UpdateArrivalTime(param);
        }
        /// <summary>
        /// 批量修改裸钻付款状态
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string UpdateReciptStatus(string param)
        {
            return CWholesalers.UpdateReciptStatus(param);
        }
        /// <summary>
        /// 获取采购名称
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string GetPurchaseAgents(string param)
        {
            return CWholesalers.GetPurchaseAgents(param);
        }
        #region  批量上下架
        public string OnStocksBatch(string param)
        {
            return CWholesalers.StocksBatch(param, "上架成功");
        }
        public string OffStocksBatch(string param)
        {
            return CWholesalers.StocksBatch(param, "下架成功");
        }
        public string updateOrder(string param)
        {
            return CWholesalers.updateOrder(param);
        }
        #endregion
        #region 更新 所在地 ,原供应商
        public string UpdatePlace(string param)
        {
            return CWholesalers.UpdatePlace(param);
        }
        public string UpdatePurchaseSupplier(string param)
        {
            return CWholesalers.UpdatePurchaseSupplier(param);
        }
        #endregion
        #region  充值 和 复核
        /// <summary>
        /// COPY PayOrders方法
        /// 余额收款（1.更新订单支付状态为1已支付，2.更新客户余额） 12-10 (重中之重)
        /// </summary>
        /// <param name="stockOrdersParam"></param>
        /// <returns></returns>充值
        public string PayAndRechargeOrders(string payOrdersParam)
        {
            return CWholesalers.PayAndRechargeOrders(payOrdersParam);
        }
        /// <summary>
        /// 复核
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string ReVerify(string param)
        {
            return CWholesalers.ReVerify(param);
        }
        #endregion
        #region 用户上传文件日志
        public string getUserLogByUserId(string param)
        {
            return CWholesalers.getUserLogByUserId(param);
        }
        #endregion
        #region 批量修改订单买价 和现货订单买价
        public string updatePriceUSD(string param)
        {
            return CWholesalers.updatePriceUSD(param);
        }
        public string updateBuyUSDPrice(string param)
        {
            return CWholesalers.updateBuyUSDPrice(param);
        }
        #endregion
        #region 客户权限
        public string GetCustomerRights(string param)
        {
            return CWholesalers.GetCustomerRights(param);
        }
        public string SubmitCustomerRights(string param)
        {
            return CWholesalers.SubmitCustomerRights(param);
        }
        #endregion
        #region 批量修改采汇
        /// <summary>
        /// 批量修改采汇
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string updatePurchaseExchangerate(string param)
        {
            return CWholesalers.updatePurchaseExchangerate(param);
        }
        #endregion
        #region 现货修改买价 汇率
        /// <summary>
        /// 现货修改买价
        /// </summary>
        /// <param name="param">"filter":{"ID":["111","222"]},"factor":"1.1","field":"PurchaseUSDPerGrain"</param>
        /// <returns></returns>
        public string UpdateStockingPrice(string param)
        {
            return CWholesalers.UpdateStockingPrice(param);
        }
        /// <summary>
        /// 现货修改汇率
        /// </summary>
        /// <param name="param">"filter":{"ID":["111","222"]},"value":"7","field":"PurchaseExchange"</param>
        /// <returns></returns>
        public string UpdatesStockingPurchaseExchange(string param)
        {
            return CWholesalers.UpdatesStockingPurchaseExchange(param);
        }
        #endregion
        #region 供应商角色
        /// <summary>
        /// 批量修改供应商角色
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string BatchUpdateSupplierRoleIDBySupplierIDs(string param)
        {
            return CWholesalers.BatchUpdateSupplierRoleIDBySupplierIDs(param);
        }
        /// <summary>
        /// /// 批量修改客户供应商角色
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string BatchUpdateCustomerRoleNameByCustomerIDs(string param)
        {
            return CWholesalers.BatchUpdateCustomerRoleNameByCustomerIDs(param);
        }
        public string AddSupplierRole(string param)
        {
            return CWholesalers.OptionSupplierRole(param, "add");
        }
        public string DelSupplierRole(string param)
        {
            return CWholesalers.OptionSupplierRole(param, "del");
        }
        public string EditSupplierRole(string param)
        {
            return CWholesalers.OptionSupplierRole(param, "edit");
        }
        public string QuerySupplierRole(string param)
        {
            return CWholesalers.QuerySupplierRole(param);
        }
        #endregion
        #region# 得到配置信息通过key
        public string GetRemoteKeyInfo(Dictionary<string, string> dict)
        {
            return CWholesalers.GetRemoteKeyInfo(dict);
        }
        public string PreBatchExecuteSql(string sql)
        {
            return CWholesalers.PreBatchExecuteSql(sql);
        }
        public static string BatchExecuteSql(string dbName, string preSql)
        {
            string result = string.Empty;
            try
            {
                IDbCommand cmdSql = YZ.GetDatabase(dbName).CreateCommand();
                cmdSql.CommandText = @preSql;
                if (preSql.Contains("select") && !preSql.Contains("trigger"))
                {
                    cmdSql.ExecuteReader();
                }
                else
                {
                    result = cmdSql.ExecuteNonQuery().ToString();
                }
            }
            catch (Exception ee)
            {
                result = "<b style='color:red'>" + ee.Message + "</b>";
            }
            return result;
        }
        #endregion
        #region 微信登录
        /// <summary>
        ///  拿到客户折扣，wx
        /// </summary>
        /// <param name="param"></param> 
        /// <returns></returns>
        public string GetCustomerDiscountsByCustomerId(string param)
        {
            return CWholesalers.GetCustomerDiscountsByCustomerId(param);
        }
        /// <summary>
        /// 微信前端只需要客户id及折扣及权限
        /// </summary>
        /// <param name="openid"></param>
        /// <param name="tttagKey"></param>
        /// <returns></returns>
        public string GetCustomerIDAndDiscountsAndRightsByOpenId(string openid, string tttagKey)
        {
            return CWholesalers.GetCustomerIDAndDiscountsAndRightsByOpenId(openid, tttagKey);
        }
        public string AddWXCustomer(string param, string tttagKey)
        {
            return CWholesalers.AddWXCustomer(param, tttagKey);
        }
        public string BindOnAccount(string param, string openId)
        {
            return CWholesalers.BindOnAccount(param, openId);
        }
        public string GetCustomerInfoAndRights(string customerInfoParam)
        {
            return CWholesalers.GetCustomerInfoAndRights(customerInfoParam);
        }
        #endregion
        #region 统计出货单各状态数量
        /// <summary>
        /// 统计出货单各状态数量
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string GetOrderShipNoCount(string param)
        {
            return CWholesalers.GetOrderShipNoCount(param);
        }
        #endregion
        #region
        /// <summary>
        ///增加库存报告参数
        /// </summary>
        public string AddAssessments(string assessmentsParam)
        {
            return CWholesalers.AddAssessments(assessmentsParam);
        }
        /// <summary>
        ///修改库存报告参数
        /// </summary>
        public string EditAssessments(string assessmentsParam)
        {
            return CWholesalers.EditAssessments(assessmentsParam);
        }
        /// <summary>
        ///删除库存报告参数
        /// </summary>
        public string DeleteAssessments(string assessmentsParam)
        {
            return CWholesalers.DeleteAssessments(assessmentsParam);
        }
        /// <summary>
        ///获取库存参数
        /// </summary>
        public string GetAssessments(string assessmentsParam)
        {
            return CWholesalers.GetAssessments(assessmentsParam);
        }
        /// <summary>
        ///下载库存报告
        /// </summary>
        public string DownloadAssessments(string assessmentsParam)
        {
            return CWholesalers.DownloadAssessments(assessmentsParam);
        }
        /// <summary>
        ///获取库存报告
        /// </summary>
        public string GetStocksReports(string assessmentsParam)
        {
            return CWholesalers.GetStocksReports(assessmentsParam);
        }
        /// <summary>
        ///库存必备
        /// </summary>
        public string GetStockRequirement(string strParam)
        {
            return CWholesalers.GetStockRequirement(strParam);
        }
        /// <summary>
        ///获取调价列表
        /// </summary>
        public string GetStockPricesAdjuster(string assessmentsParam)
        {
            return CWholesalers.GetStockPricesAdjuster(assessmentsParam);
        }
        #endregion
        #region 获取 供应商和角色
        public string GetSupplierRoleList(string param)
        {
            return CWholesalers.GetSupplierRoleList(param);
        }
        /// <summary>
        /// 更新屏蔽中供应商角色
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string UpdateSupplierRole(string param)
        {
            return CWholesalers.UpdateSupplierRole(param);
        }
        #endregion
        #region 用户登录操作日志
        public delegate void UserLogInfos(string strParam);
        #endregion
        #region 解析IP地址
        public string ParsingIP(string ip)
        {
            return CWholesalers.ParsingIP(ip);
        }
        #endregion
        #region 借货单
        /// <summary>
        /// 添加借货单(单个或多个)  --含事务
        /// </summary>
        /// <param name="multiAddToCartParam"></param>
        /// <returns></returns>
        public string AddLendOrder(string strParam)
        {
            return CWholesalers.AddLendOrder(strParam);
        }
        /// <summary>
        /// 借货单列表
        /// </summary>
        /// <param name="cartsParam"></param>
        /// <returns></returns>
        public string GetLendOrderListOfDiamond(string cartsParam)
        {
            return CWholesalers.GetLendOrderListOfDiamond(cartsParam);
        }
        
        /// <summary>
        /// 借货单列表明细
        /// </summary>
        /// <param name="cartsParam"></param>
        /// <returns></returns>
        public string SearchLendOrderByLendOrderNO(string cartsParam)
        {
            return CWholesalers.SearchLendOrderByLendOrderNO(cartsParam);
        }

        /// <summary>
        /// 移除借货单
        /// </summary>
        /// <param name="ringCartId"></param>
        /// <returns></returns>
        /// <summary>
        public string RemoveLendOrderOfDiamond(string strParam)
        {
            return CWholesalers.RemoveLendOrderOfDiamond(strParam);
        }
        /// <summary>
        /// 裸钻提交借货单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        /// <summary>
        /// 裸钻提交借货单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SubmitLendOrders(string strParam)
        {
            string name = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logParam = strParam;
                HashParam param = Json.Deserialize<HashParam>(strParam);
            string tttagKey = CommonUrl.getURL(param,strParam, "提交借货单");
            StringBuilder sbMsg = new StringBuilder();
            lock (typeof(Distribution))
            {
                var orderInfoMessage = "提交借货单1——提交参数：" + strParam;
                sbMsg.Append(orderInfoMessage + "\r\n");
                StringBuilder tempSns = new StringBuilder();
                #region 查询借货单
                HashParam hash = new HashParam();
                hash.Add("GoodsTypeID", 1);
                hash.Add("InventoryIDs", param.GetString("InventoryIDs").TrimEnd(',').Split(',').ToArray());
                IList<LendOrder> LendOrderList = YZ.GetDatabase(tttagKey).QueryForList<LendOrder>("LendOrder.LendOrderList", hash);//发货单
                if (LendOrderList != null)
                {
                    if (LendOrderList[0].IsReturn == 0)
                        return CommonLog.MsgErrorInfo("还未选调价方式");// 
                }
                #endregion
                int addOrderResult = 0;//生成订单结果
                TransmissionOrderResult submitOrderResult1 = new TransmissionOrderResult();
                try
                {
                    #region
                    var failCount = 0;
                    var successCount = 0;
                    var failCount1 = 0;
                    var successCount1 = 0;
                    #endregion
                    //用来操作移除非现货供应商的货
                    List<int> list = param.GetString("InventoryIDs").TrimEnd(',').Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Int32.Parse).ToList();// new System.Collections.ArrayList(InventoryIDs);
                    if (list.Count <= 0) return CommonLog.MsgErrorInfo("未选择任何订单");
                    if (param.GetString("CustomerID") == "undefined" || param.GetString("CustomerID") == "")
                    { //客户登录信息消失或失效
                        return CommonLog.MsgErrorInfo("客户登录失效");//CustomerID一定要存在
                    }
                    if (!param.ContainsKey("OrderType"))
                    { //客户登录信息消失或失效
                        return CommonLog.MsgErrorInfo("OrderType error");//OrderType一定要存在
                    }
                    CustomerInfo _customerInfo = YZ.GetDatabase(tttagKey).Get<CustomerInfo>(param.GetInt("CustomerID"));
                    orderInfoMessage = string.Format("提交借货单2——客户信息{0}--退点：{1}，彩色退点：{2},优惠：{3}", _customerInfo.UserName, _customerInfo.Rebate, _customerInfo.FancyRebate, _customerInfo.Discounts);
                    sbMsg.Append(orderInfoMessage + "\r\n");
                    if (_customerInfo == null)
                    {
                        return CommonLog.MsgErrorInfo("客户标识不存在");//CustomerID一定要存在
                    }
                    else
                    {
                        #region
                        var iParam = new
                        {
                            ID = list.ToArray(),
                            CustomerID = _customerInfo.CustomerID,
                            IsFancy = -1 //订单不用传
                        };
                        var inventoryJson = GetInventoryInfos(JsonConvert.SerializeObject(iParam), tttagKey);
                        orderInfoMessage = "提交借货单3——数据中心格式化后信息:" + inventoryJson;
                        sbMsg.Append(orderInfoMessage + "\r\n");
                        var inventoryData = new { data = new object() };
                        var anonymousData = JsonConvert.DeserializeAnonymousType(inventoryJson, inventoryData);
                        // TransmissionOrderResult getOrderResult = PublicInterface.OprationOrders(InventoryIDs, "get");//OprationOrders 没有成功调用的话 不会提交
                        if (inventoryJson != "")
                        {
                            //var responseJson = MyHttpRequest.ConvertToInventoryFormat(inventoryJson); //转化成库存的Json格式
                            PageList<InventoryInfoResult> _SoldInventoryInfos = JsonConvert.DeserializeObject<PageList<InventoryInfoResult>>(JsonConvert.SerializeObject(anonymousData.data));//转成PageList
                            orderInfoMessage = "提交借货单4——数据中心格式化InventoryInfoResult后信息:" + JsonConvert.SerializeObject(_SoldInventoryInfos);
                            sbMsg.Append(orderInfoMessage + "\r\n");
                            if (_SoldInventoryInfos != null && _SoldInventoryInfos.Data.Count > 0)
                            {
                                SysSettingInfo setting = GoodsType.GetSystemSetting(tttagKey, GoodsType.Diamond);
                                orderInfoMessage = string.Format("提交借货单5——设置信息 币种：{0},销售汇率：{1},采购汇率：{2},全局退点（白）：{3},全局退点（彩）：{4}，分组折扣（白）：{5},分组折扣（彩）：{6},分组倍率：{7}"
                                                                               , setting.CurrentSet, setting.Rate, setting.PurchaseExchangerate, setting.GlobalDiscountReturn, setting.GlobalFancyDiscountReturn, setting.Group4C, setting.GroupFancy4C, setting.GroupAmount);
                                sbMsg.Append(orderInfoMessage + "\r\n");
                                #region
                                foreach (var item in _SoldInventoryInfos.Data)
                                {
                                    if (item.Supplier.ToUpper() != tttagKey)
                                    {
                                        list.RemoveAt(list.IndexOf(Convert.ToInt32(item.ID)));
                                    }
                                    //DiamondsPriceHandlers.ComputePrice(item, _customerInfo, setting); 库存查询时已计算
                                }
                                orderInfoMessage = "提交借货单6——现货信息:" + JsonConvert.SerializeObject(list);
                                sbMsg.Append(orderInfoMessage + "\r\n");
                                #endregion
                                //有至少一个成功下单，将有两大事务：生成本地订单和移除购物车
                                #region
                                //单个订单生成成功 
                                for (int j = 0; j < _SoldInventoryInfos.Data.Count; j++)
                                {
                                    //单粒库存
                                    InventoryInfoResult _inventoryInfo = (InventoryInfoResult)_SoldInventoryInfos.Data[j];//必须是InventoryInfoResult类型    
                                    orderInfoMessage = "提交借货单7[" + j.ToString() + "]—_inventoryInfo信息:" + JsonConvert.SerializeObject(_inventoryInfo);
                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                    var orderParam = new OrderInfo() { InventoryID = _inventoryInfo.ID, CertNo = _inventoryInfo.CertNo };
                                    OrderInfo orderInfo = YZ.GetDatabase(tttagKey).QueryForObject<OrderInfo>("Order.SelectOrderByInventoryID", orderParam);
                                    if (orderInfo == null)  //防止重复正常的订单 12345为正常的订单
                                    {
                                        if (_inventoryInfo != null)
                                        {
                                            int[] cartIds = { (int)_inventoryInfo.ID };//这个是用来批量删除购物车的id
                                            //赋值
                                            #region  本地订单添加
                                            OrderInfo _order = new OrderInfo();
                                            _order.CreateTime = DateTime.Now;//下单时间 
                                            _order.Remarks = param.ContainsKey("Remarks") ? param.GetString("Remarks").Replace(" ", "") : ""; //客户下单备注 (去除空格 255长度)
                                            if (_inventoryInfo.Supplier.ToUpper() == tttagKey)
                                            {
                                                //检查到货时间是否为空
                                                if (!string.IsNullOrEmpty(_inventoryInfo.ArrivalTime))
                                                {
                                                    //现货
                                                    _order.OrderStatus = 3;//订单状态 3（待出货）
                                                    _order.DeliveryTime = DateTime.Now;//发货时间 2017-02-10 
                                                    _order.ArrivalTime = _inventoryInfo.ArrivalTime;
                                                    _order.Arrival = 1;//
                                                }
                                                else
                                                {
                                                    _order.OrderStatus = 2;
                                                }
                                                //现货特有  买入时间，到货时间，付款状态，备注，采购人
                                                if (!string.IsNullOrEmpty(_inventoryInfo.PurchaseTime))
                                                    _order.PurchaseTime = Convert.ToDateTime(_inventoryInfo.PurchaseTime);//买入时间 
                                                _order.ReceiptStatus = _inventoryInfo.ReceiptStatus;//付款状态
                                                if (!string.IsNullOrEmpty(_inventoryInfo.PurchaseAgent))
                                                {
                                                    UserInfo userinfo = YZ.GetDatabase(tttagKey).QueryForObject<UserInfo>("User.getPurchaseAgentIdByName", _inventoryInfo.PurchaseAgent);
                                                    if (userinfo != null)
                                                        _order.PurchaseUserID = userinfo.UserID;
                                                }
                                            }
                                            else
                                            {
                                                _order.ReceiptStatus = 0;//付款状态
                                                //定货
                                                _order.OrderStatus = 1;//订单状态 1（下单成功，采购中）
                                            }
                                            _order.PaymentStatus = 0;//收款状态 0
                                            _order.CustomerID = param.GetInt("CustomerID") ?? 0;  //客户ID
                                            //默认没有采购了，所以注释先
                                            //UserInfo userinfo = YZ.GetDatabase(tttagKey).QueryForObject<UserInfo>("User.getPurchaseAgentIdByName", _inventoryInfo.PurchaseAgent);
                                            //if (userinfo != null)
                                            //    _order.PurchaseUserID = userinfo.UserID;
                                            _order.SalesUserID = Convert.ToInt32(_customerInfo.SalesUserID);//销售ID
                                            _order.OrderType = param.GetInt("OrderType");//订单类型 (1客主 2代客 3 录入 4 二级） 9-10
                                            _order.SN = _inventoryInfo.SN;//货号
                                            _order.InventoryID = _inventoryInfo.ID;//库存ID
                                            _order.OriginSN = _inventoryInfo.OriginSN;//原货号
                                            _order.Weight = _inventoryInfo.Weight;//重量
                                            _order.CertNo = _inventoryInfo.CertNo;//证书号
                                            _order.SupplierCode = _inventoryInfo.Supplier;//供应商
                                            _order.Color = _inventoryInfo.Color;//颜色
                                            _order.Clarity = _inventoryInfo.Clarity;//净度
                                            _order.Symmetry = _inventoryInfo.Symmetry;//对称
                                            _order.Polish = _inventoryInfo.Polish;//抛光
                                            _order.IsFancy = _inventoryInfo.IsFancy;//是否彩钻
                                            _order.CertType = _inventoryInfo.CertType;//证书类型
                                            _order.Fluorescence = _inventoryInfo.Fluorescence;//荧光
                                            _order.Place = _inventoryInfo.Place;//所在地
                                            _order.Milky = _inventoryInfo.Milky;//奶油
                                            _order.BlackDefect = _inventoryInfo.BlackDefect;//黑点
                                            _order.Hue = _inventoryInfo.Hue;//色调
                                            _order.HA = _inventoryInfo.HA;//心箭
                                            _order.OtherDefect = _inventoryInfo.OtherDefect;//其他瑕疵
                                            _order.EyeClean = _inventoryInfo.EyeClean;//肉眼干净
                                            _order.Measurement = _inventoryInfo.Measurement;//尺寸  
                                            _order.Shape = _inventoryInfo.Shape;//形状
                                            _order.Cut = _inventoryInfo.Cut;//切工
                                            _order.Rapnet = _inventoryInfo.Rapnet;//国际报价（数据中心订单Rapnet始终为null）
                                            _order.Status = 2;//   借出 _inventoryInfo.Status;//货品状态 8-19
                                            _order.MediaID = _inventoryInfo.MediaID;
                                            _order.HasImage = _inventoryInfo.HasImage;
                                            _order.HasVideo = _inventoryInfo.HasVideo;
                                            _order.HasAtlas = _inventoryInfo.HasAtlas;
                                            _order.PurchaseSupplier = _inventoryInfo.PurchaseSupplier;//采购供应商
                                            //_order.PurchaseAgent= _inventoryInfo.PurchaseAgent;
                                            _order.PurchaseExchangerate = GoodsType.GetPurchaseExchangeRate(setting);//采购汇率 
                                            _order.PriceUSD = _inventoryInfo.SourceDolarPerGrain;//买入美金
                                            _order.PurchaseRMB = _order.PriceUSD * _order.PurchaseExchangerate;//买入RMB
                                            _order.DiscountReturn = _inventoryInfo.SourceDiscountReturn;//买入退点
                                            _order.SalesExchangerate = GoodsType.GetRate(setting);//销售汇率  
                                            //要根据借货单调整的价格来计算
                                            LendOrder lendOrder = LendOrderList.Where(p => p.GoodsID.Value == _inventoryInfo.ID.Value).First();
                                            if (lendOrder == null) continue;
                                            if (lendOrder.IsReturn.Value == 1)
                                            {
                                                _order.Confirmdiscount = _inventoryInfo.SourceDiscountReturn + lendOrder.IsReturnValues;//退点
                                                //美元单粒价 		= RAPNET * (100 + 相应退点) / 100 * 重量
                                                _order.ConfirmUSD = _order.Rapnet * (100 + _order.Confirmdiscount) / 100 * _order.Weight;
                                                _order.ConfirmPrice = _order.ConfirmUSD.Value * _order.SalesExchangerate.Value;
                                            }
                                            else if (lendOrder.IsReturn.Value == 2)
                                            {
                                                //美元单粒价 		= RAPNET * (100 + 相应退点) / 100 * 重量
                                                _order.ConfirmUSD = _inventoryInfo.SourceDolarPerGrain * lendOrder.IsReturnValues;
                                                _order.ConfirmPrice = _order.ConfirmUSD.Value * _order.SalesExchangerate.Value;
                                                _order.Confirmdiscount = AllPublic.CalcWhiteReturnPoint(_order.IsFancy, _order.ConfirmUSD, _order.Rapnet, _order.Weight, _customerInfo.Discounts, _order.PriceUSD);//最后成交退点
                                            }
                                            else
                                            {
                                                _order.ConfirmUSD = 0;
                                                _order.ConfirmPrice = 0;
                                                _order.Confirmdiscount = 0;
                                            }
                                            //_order.ConfirmUSD = _inventoryInfo.CustomerDolarPerGrain.Value * _customerInfo.Discounts.Value;//卖出美金 = 客户美金总价 2017-01-19
                                            ////卖出价格
                                            //_order.SalesExchangerate = GoodsType.GetRate(setting);//销售汇率 
                                            //_order.ConfirmPrice = _order.ConfirmUSD.Value * _order.SalesExchangerate.Value;//最后成交卖出人民币总价 *优惠
                                            //买入价格 
                                            orderInfoMessage = "提交订单8[" + j.ToString() + "]——_order信息:" + JsonConvert.SerializeObject(_order);
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                            //新增原供应商
                                            _order.PurchaseSupplier = _inventoryInfo.PurchaseSupplier;
                                            if (_order.SupplierCode.ToUpper() == tttagKey)
                                            {
                                                _order.BuyDis = _inventoryInfo.PurchaseDiscountReturn.Value;
                                                _order.BuyRMBPrice = Math.Round(_inventoryInfo.PurchaseRMB.Value, 3); //Math.Round(_inventoryInfo.PurchaseUSDPerGrain.Value * _order.SalesExchangerate.Value, 3);
                                                _order.BuyUSDPrice = Math.Round(_inventoryInfo.PurchaseUSDPerGrain.Value, 3);
                                            }
                                            orderInfoMessage = "提交订单9[" + j.ToString() + "]——_order信息:" + JsonConvert.SerializeObject(_order);
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                            #endregion
                                            using (ITransaction trans_addOrder = YZ.GetTransaction(tttagKey))
                                            {
                                                //执行
                                                #region  执行事物，更新借货单状态1
                                                try
                                                {
                                                    addOrderResult = trans_addOrder.Add(_order);//生成单条订单 
                                                    //单条订单生成成功,就移除购物车。
                                                    if (addOrderResult > 0)
                                                    {
                                                        if (j == 0)  //加入1个sn
                                                            tempSns.Append(_order.SN);
                                                        //现货 
                                                        try
                                                        {
                                                            //立即购买 流程
                                                            try
                                                            {
                                                                //更新借货单状态1
                                                                ComLendOrder.UpdateLendOrder(GoodsType.Diamond, tttagKey, param.GetString("CustomerID"), cartIds);
                                                                trans_addOrder.CommitTransaction(); // 提交订单
                                                                successCount++;
                                                                orderInfoMessage = "提交借货单10[" + j.ToString() + "]成功" + "——_order信息:" + JsonConvert.SerializeObject(_order);
                                                                sbMsg.Append(orderInfoMessage + "\r\n");
                                                            }
                                                            catch (Exception exc)
                                                            {
                                                                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), exc);
                                                                trans_addOrder.RollBackTransaction();//回滚事务
                                                                failCount++;
                                                                orderInfoMessage = "提交借货单异常1[" + j.ToString() + "]" + "——_order信息:" + JsonConvert.SerializeObject(_order) + "异常信息==>" + exc.StackTrace;
                                                                sbMsg.Append(orderInfoMessage + "\r\n");
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            failCount++;
                                                            CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                                                            orderInfoMessage = "提交借货单异常2[" + j.ToString() + "]" + JsonConvert.SerializeObject(_order) + "异常信息==>" + ex.StackTrace + "参数:" + logParam;
                                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                                            return CommonLog.MsgErrorInfo("移除购物车：程序错误：");
                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    failCount++;
                                                    CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                                                    orderInfoMessage = "提交借货单异常3[" + j.ToString() + "]" + JsonConvert.SerializeObject(_order) + "异常信息==>" + ex.StackTrace + "参数:" + logParam;
                                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                                    return CommonLog.MsgErrorInfo("生成订单，程序错误");
                                                }
                                                #endregion
                                            }
                                        }
                                    }
                                    else
                                    {
                                        failCount++;
                                    }
                                }
                                #endregion
                            }
                            CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), null, orderInfoMessage);
                        }
                        else
                        {
                            return CommonLog.MsgErrorInfo("获取信息失败，请重试");
                        }
                        #endregion
                        ////调用订单提交接口  下单 不走数据中心
                        #region
                        if (list.Count > 0 && successCount > 0) //还有现货，则提交
                        {
                            try
                            {
                                TransmissionOrderResult submitOrderResult = AllPublic.OprationOrders(list.ToArray(), "add", tttagKey);//提交订单 InventoryID  (OprationOrders 包含了提交订单、删除订单 和获取订单)
                                if (submitOrderResult != null && submitOrderResult.Successful != null && submitOrderResult.Failed != null)
                                {
                                    successCount1 = submitOrderResult.Successful.Length;
                                    failCount1 = submitOrderResult.Failed.Length;
                                }
                                if (submitOrderResult == null || submitOrderResult.Successful == null || successCount1 > 0)
                                {
                                    //提交成功的从list移除，list为要删除的本地订单列表
                                    if (successCount1 > 0)
                                    {
                                        for (int i = 0; i < submitOrderResult.Successful.Length; i++)
                                        {
                                            list.Remove(submitOrderResult.Successful[i]);
                                        }
                                    }
                                    //网络或其它原因的失败也删除本地订单
                                    else
                                    {
                                        successCount1 = -1;
                                        failCount1 = -1;
                                    }
                                    //删除本地订单list.ToArray()
                                    if (list.Count > 0)
                                    {
                                        HashParam _p = new HashParam();
                                        _p.Add("InventoryIDs", list.ToArray()); //要移除的现货list
                                        int _r = YZ.GetDatabase(tttagKey).Delete("Order.DelOrdersByInventoryIds", _p); //删除本地订单结果
                                        if (_r == 0)  //出现删除未成功提交的订单失败则
                                        {
                                            orderInfoMessage = "删除【提交数据中心失败的订单】失败，状态为2，3的失败InventoryID为：" + JsonConvert.SerializeObject(list);
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                        }
                                        else
                                        {
                                            foreach (var item in list)
                                            {
                                                successCount--; //删除订单成功的数量对应减少
                                            }
                                        }
                                    }
                                }
                                failCount = failCount1;
                                orderInfoMessage = "提交订单11，数据中心返回结果：" + JsonConvert.SerializeObject(submitOrderResult);
                                sbMsg.Append(orderInfoMessage + "\r\n");
                            }
                            catch (Exception ex)
                            {
                                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                                orderInfoMessage = "删除【提交数据中心失败的订单】失败，状态为2，3的失败InventoryID为：" + JsonConvert.SerializeObject(list) + "异常信息==>" + ex.StackTrace + "参数:" + logParam;
                                sbMsg.Append(orderInfoMessage + "\r\n");
                                Logger.Error(typeof(Distribution), "SubmitOrder:7300");
                                successCount1 = -1;
                                failCount1 = -1;
                                throw;
                            }
                        }
                        #endregion
                        if (successCount == 0 && successCount1 == 0 && failCount == 0 && failCount1 == 0)
                        {
                            failCount = list.Count;
                        }
                        var msg = new
                        {
                            Successful = successCount,
                            Successful1 = successCount1,
                            Failed = failCount,
                            Failed1 = failCount1,
                        };
                        if (successCount > 0)//成功则发送短信
                        {
                            UserInfo userInfo = new UserInfo();
                            if (_customerInfo.SalesUserID != null)
                            {
                                userInfo = YZ.GetDatabase(tttagKey).Get<UserInfo>(_customerInfo.SalesUserID.Value);
                                if (userInfo != null)
                                {
                                    #region
                                    var snStr = tempSns.ToString();
                                    var orderType = param.GetInt("OrderType");//订单类型 (1客主 2代客 3 录入 4 二级） 9-10
                                    if (userInfo.Mobile != null)
                                    {
                                        // > 10  有可能有国外号码
                                        if (AllPublic.IsPhoneNo(userInfo.Mobile) && orderType == 1)
                                        {
                                            CWholesalers.SendMsgAsync(userInfo.Mobile, userInfo.RealName, _customerInfo.NickName, snStr);  //业务
                                            orderInfoMessage = "提交订单12 成功后发送消息给业务员，业务员信息:" + JsonConvert.SerializeObject(userInfo);
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                        }
                                        //if (userInfo.Mobile != _customerInfo.Mobile && IsPhoneNo(_customerInfo.Mobile) && orderType == 2) //客户
                                        if (AllPublic.IsPhoneNo(_customerInfo.Mobile) && orderType == 2) //客户
                                        {
                                            CWholesalers.SendMsgAsync(_customerInfo.Mobile, "", "您", snStr);
                                            orderInfoMessage = "提交订单13 成功后发送消息给客户，客户信息:" + JsonConvert.SerializeObject(_customerInfo);
                                            sbMsg.Append(orderInfoMessage + "\r\n");
                                        }
                                        //if (userInfo.Mobile != _customerInfo.Mobile && userInfo.Mobile != tel && tel.Length > 10)
                                        //    SendMsg(tel, "管理员", _customerInfo.NickName, snStr);//admin
                                    }
                                    #endregion
                                }
                                else
                                {
                                    orderInfoMessage = "提交订单14 下单成功，发短信失败，客户对应的用户已不存在！客户对应的ID是:" + _customerInfo.SalesUserID.Value;
                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                    CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), null, "下单成功，发短信失败，客户对应的用户已不存在！");
                                }
                            }
                            else
                            {
                                Link link = YZ.GetDatabase(tttagKey).Get<Link>(1);//系统管理员号码
                                var tel = "";
                                if (link != null)
                                    tel = link.Telphone.ToString();
                                if (tel.Length > 10 && AllPublic.IsPhoneNo(tel))
                                {
                                    CWholesalers.SendMsgAsync(tel, "管理员", _customerInfo.NickName, tempSns.ToString());//admin 
                                    orderInfoMessage = "提交订单15 发短信给管理员，管理员电话:" + tel + ";客户昵称:" + _customerInfo.NickName + "货号:" + tempSns.ToString();
                                    sbMsg.Append(orderInfoMessage + "\r\n");
                                }
                            }
                        }
                        orderInfoMessage = "提交订单16 成功，返回消息" + JsonConvert.SerializeObject(msg);
                        sbMsg.Append(orderInfoMessage + "\r\n");
                        return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(msg));
                    }
                }
                catch (Exception ex)
                {
                    CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                    CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), null, orderInfoMessage);
                    orderInfoMessage = "提交订单17异常，消息：" + ex.StackTrace + "参数:" + logParam;
                    return CommonLog.MsgErrorInfo("提交订单：程序错误：");
                }
                finally
                {
                    CommonLog.SendMQMsg(tttagKey, sbMsg.ToString());
                }
            }
        }
        /// <summary>
        /// 更新借货单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string UpdateLendOrderByNo(string strParam)
        {
            return CWholesalers.UpdateLendOrderByNo(strParam);
        }
        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetLendOrderByNo(string strParam)
        {
            return CWholesalers.GetLendOrderByNo(strParam);
        }
        /// <summary>
        /// 提交借货单 除裸钻外
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SubmitProductLendoder(string strParam)
        {
            return CWholesalers.SubmitProductLendoder(strParam);
        }
        #endregion
        #region 上传裸钻图片地址
        public string UploadDiamondImg(string strParam)
        {
            return CWholesalers.UploadDiamondImg(strParam);
        }
        /// <summary>
        /// 获取裸钻图片
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetImgInfo(string strParam)
        {
            return CWholesalers.GetImgInfo(strParam);
        }
        /// <summary>
        /// 上传之前需要获取到 STS token
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetSTSToken(string strParam)
        {
            return CWholesalers.GetSTSToken(strParam);
        }
        #endregion
        #region &&&&&&&&&&&&&&&&&&&&&上传  &&&&&&&&&&&&&&&&&&&&&
        public string GetRapnetInfo(string param)
        {
            return CWholesalers.GetRapnetInfo(param);
        }
        public string EditRapnetInfo(string param)
        {
            return CWholesalers.EditRapnetInfo(param);
        }
        public string AddRapnetInfo(string param)
        {
            return CWholesalers.AddRapnetInfo(param);
        }
        //下载数据中心的csv或excel
        public string GetDataCenterDataAndUploadRapnet(string exportParam)
        {
            return CWholesalers.GetDataCenterDataAndUploadRapnet(exportParam);
        }
        #endregion  &&&&&&&&&&&&&&&&&&&&&上传rapnet&&&&&&&&&&&&&&&&&&&&&
        #region &&&&&&&&&&&&&&&&&&&&&销售报告&&&&&&&&&&&&&&&&&&&&&一共 5 个子模块：访问，订单，利润，延期，资产
        //访问    /api/report/visit
        public string ReportAboutVisit(string param)
        {
            return AllPublic.ReportAboutVisit(param);
        }
        //订单   /api/report/order
        public string ReportAboutOrder(string param)
        {
            return AllPublic.ReportAboutOrder(param);
        }
        //利润    /api/report/profit
        public string ReportAboutProfit(string param)
        {
            return AllPublic.ReportAboutProfit(param);
        }
        //延期    /api/report/delay
        public string ReportAboutDelay(string param)
        {
            return AllPublic.ReportAboutDelay(param);
        }
        //资产    /api/report/assets
        public string ReportAboutAssets(string param)
        {
            return AllPublic.ReportAboutAssets(param);
        }
        //价格报告增加这两个字段，需求退点，pointer数据更新时间。 
        // /dpi/pointer?is_fancy=0&shape=1&weight_start=0.30&color=D&clarity=VVS2&cut_class=EX&fluorescence_class=N&cert_type=GIA 
        public string GetDpiPointer(string strParam)
        {
            return AllPublic.GetDpiPointer(strParam);
        }
        #endregion &&&&&&&&&&&&&&&&&&&&&销售报告&&&&&&&&&&&&&&&&&&&&&
        #region 查宝网提交订单到88gia网站创建订单专用方法
        static readonly object objDefaultSales = new object();
        public string CreateOrder(string strParam)
        {
            logParam = strParam;
                HashParam param = Json.Deserialize<HashParam>(strParam);
            string tttagKey = CommonUrl.getURL(param,strParam, "查宝网下单");
            try
            {
                int SalesID = GetDefaultSales(strParam, tttagKey);
                if (SalesID > 0)
                {
                    int CustomerID = GetCustomerID(strParam, tttagKey, SalesID);
                    if (CustomerID > 0)
                    {
                        //{"CustomerID":1,"OrderType":1,"InventoryIDs":"11034643","Remarks":"1"}
                        HashParam hsParam = new HashParam();
                        hsParam.Add("CustomerID", CustomerID);
                        hsParam.Add("OrderType", 1);
                        hsParam.Add("InventoryIDs", param.GetString("InventoryIDs"));
                        string remark = param.ContainsKey("Remarks") ? param.GetString("Remarks") : "查宝网下单";
                        if (remark.Trim().Length == 0) remark = "查宝网下单";
                        hsParam.Add("Remarks", remark);
                        hsParam.Add("TagKey", tttagKey);
                        var JsonParam = JsonConvert.SerializeObject(hsParam);
                        return SubmitOrder(JsonParam);
                    }
                    else
                    {
                        return CommonLog.MsgErrorInfo("88gia没找客户信息(" + param.GetString("CustomerName") + ")");
                    }
                }
                else
                {
                    return CommonLog.MsgErrorInfo("88gia没找到默认业务");
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：查宝网异常" + ex.Message);
                return CommonLog.MsgErrorInfo("程序错误");
            }
        }
        /// <summary>
        /// 获取默认业务ID
        /// </summary>
        /// <param name="strParam"></param>
        /// <param name="tttagKey"></param>
        /// <returns></returns>
        public int GetDefaultSales(string strParam, string tttagKey)
        {
            try
            {
                lock (objDefaultSales)
                {
                    UserInfo user = YZ.GetDatabase(tttagKey).QueryForObject<UserInfo>("User.getDefaultSales", null);
                    if (user != null)
                        return user.UserID;
                    else
                    {
                        //创建user
                        UserInfo userinfo = new UserInfo();
                        userinfo.UserName = "DefaultSales";
                        userinfo.UserPassword = Yunzuan.Foundation.Safe.EncryptHelper.MD5("123456"); //"E10ADC3949BA59ABBE56E057F20F883E";//123456 md5加密后的结果
                        userinfo.RoleID = "3";//默认3是业务
                        userinfo.Sex = 1;
                        userinfo.Mobile = "";
                        userinfo.RealName = "默认业务";
                        userinfo.SysStatus = 1;
                        userinfo.DefaultFlag = 1;
                        userinfo.CreateTime = DateTime.Now;
                        using (ITransaction trans_addUser = YZ.GetTransaction(tttagKey))
                        {
                            int addUserResult = trans_addUser.Add(userinfo);
                            if (addUserResult > 0)
                            {
                                trans_addUser.CommitTransaction();
                                CommonLog.SendMQMsg(tttagKey, "创建默认业务：" + JsonConvert.SerializeObject(userinfo));
                                return addUserResult;
                            }
                            else
                            {
                                trans_addUser.RollBackTransaction();
                                return 0;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：获取88gia默认业务失败" + ex.Message);
                return 0;
            }
        }
        static readonly object objCustomerID = new object();
        public int GetCustomerID(string strParam, string tttagKey, int SalesID)
        {
            try
            {
                HashParam param = Json.Deserialize<HashParam>(strParam);
                HashParam newParam = new HashParam();
                lock (objCustomerID)
                {
                    if (param.ContainsKey("CustomerName"))
                    {
                        newParam.Add("UserName", param.GetString("CustomerName"));
                        newParam.Add("Mobile", param.GetString("CustomerName"));
                    }
                    else
                    {
                        return 0;
                    }
                    CustomerInfo _customerInfo = YZ.GetDatabase(tttagKey).QueryForObject<CustomerInfo>("Customer.GetCustomerID", newParam);
                    if (_customerInfo != null)
                    {
                        return _customerInfo.CustomerID;
                    }
                    else
                    {
                        CustomerInfo customer = new CustomerInfo();
                        customer.UserName = param.GetString("CustomerName");
                        string pwd = param.ContainsKey("CustomerPwd") ? param.GetString("CustomerPwd") : "123456";
                        if (string.IsNullOrEmpty(pwd)) pwd = "123456";
                        customer.UserPassword = Yunzuan.Foundation.Safe.EncryptHelper.MD5(pwd);
                        customer.CompanyName = param.GetString("CustomerName");
                        customer.NickName = param.GetString("CustomerName");
                        customer.SalesUserID = SalesID;
                        customer.RealName = param.GetString("CustomerName");
                        customer.SysStatus = 1;
                        customer.FancyRebate = 0;
                        customer.RingRebate = 1;
                        customer.ParcelRebate = 1;
                        customer.GemRebate = 1;
                        customer.IsRebate = 1;//1退点;0倍率
                        customer.InlaySettingsRebate = "1";
                        customer.IsSetInlaySettings = 0;//是否设置空托(0 设置为倍率 1,设置具体的值)
                        customer.Comments = "查宝网的客户";
                        customer.CreateTime = DateTime.Now;
                        using (ITransaction trans_addUser = YZ.GetTransaction(tttagKey))
                        {
                            int addUserResult = trans_addUser.Add(customer);
                            if (addUserResult > 0)
                            {
                                trans_addUser.CommitTransaction();
                                CommonLog.SendMQMsg(tttagKey, "创建客户：客户名：" + param.GetString("CustomerName") + "客户密码:" + pwd);
                                return addUserResult;
                            }
                            else
                            {
                                trans_addUser.RollBackTransaction();
                                return 0;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：获取客户ID失败" + ex.Message);
                return 0;
            }
        }
        #endregion
        #region 统计查询货品日志记录
        /// <summary>
        /// 用户登陆日志
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetUserLoginLog(string strParam)
        {
            return ConmonMQMsgClass.GetUserLoginLog(strParam);
        }
        /// <summary>
        /// 操作日志
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SearchOperationLog(string strParam)
        {
            return ConmonMQMsgClass.SearchOperationLog(strParam);
        }
        /// <summary>
        /// 统计查询货品日志记录
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetSearchLog(string strParam)
        {
            string result = "";
            result = ConmonMQMsgClass.GetSearchLog(strParam);
            return result;
        }
        /// <summary>
        /// 日志总数
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetSearchLogCount(string strParam)
        {
            string result = "";
            result = ConmonMQMsgClass.GetSearchLogCount(strParam);
            return result;
        }
        /// <summary>
        /// 统计明细
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SearchDetailByWeight(string strParam)
        {
            return ConmonMQMsgClass.SearchDetailByWeight(strParam);
        }
        /// <summary>
        /// 详细信息
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SearchDetail(string strParam)
        {
            return ConmonMQMsgClass.SearchDetail(strParam);
        }
        #endregion
        #region 后台删除数据中心订单
        /// <summary>
        /// 删除订单的xx，自己人用传参数key,IDs
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string DelOrderFromDataCenter(string strParam)
        {
            return AllPublic.DelOrderFromDataCenter(strParam);
        }
        #endregion
        #region 修改订单相关方法
        /// <summary>
        /// 新增商品
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string AddProductData(string strParam)
        {
            return CWholesalers.AddProductData(strParam);
        }
        /// <summary>
        /// 删除商品
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string DelProductData(string strParam)
        {
            return CWholesalers.DelProductData(strParam);
        }
        /// <summary>
        /// 现货修改
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyProductData(string strParam)
        {
            return CWholesalers.ModifyProductData(strParam);
        }
        /// <summary>
        /// 查货
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetProductData(string strParam)
        {
            return CWholesalers.GetProductData(strParam);
        }
        /// <summary>
        /// 查货数量
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetProductDataCount(string strParam)
        {
            return CWholesalers.GetProductDataCount(strParam);
        }
        /// <summary>
        /// 提交订单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SubmitOrderNew(string strParam)
        {
            return CWholesalers.SubmitOrderNew(strParam);
        }
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="ordersParam"></param>
        /// <returns></returns>
        public string GetOrderNewList(string strParam)
        {
            return CWholesalers.GetOrderNewList(strParam);
        }
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetOrderNew(string strParam)
        {
            return CWholesalers.GetOrderNew(strParam);
        }
        /// <summary>
        /// 采购订单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string PurchaseOrderNew(string strParam)
        {
            return CWholesalers.PurchaseOrderNew(strParam);
        }
        /// <summary>
        /// 修改订单
        /// </summary>
        /// <param name="strParam"></param>
        /// <param name="tttagKey"></param>
        /// <param name="strMark">标识</param>
        /// <returns></returns>
        public string ModifyOrderNew(string strParam, string tttagKey, string strMark)
        {
            return CWholesalers.ModifyOrderNew(strParam, tttagKey, strMark);
        }
        /// <summary>
        /// 更新订单（现货订单调用）
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string UpdateOrderNew(string strParam)
        {
            return CWholesalers.UpdateOrderNew(strParam);
        }
        /// <summary>
        /// 选采购
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyPurchaseUser(string strParam)
        {
            return CWholesalers.ModifyPurchaseUser(strParam);
        }
        /// <summary>
        /// 确认到货
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string SubmitArrivalOrdersNew(string strParam)
        {
            return CWholesalers.SubmitArrivalOrdersNew(strParam);
        }
        /// <summary>
        /// 取消到货
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string CancelArrivalOrdersNew(string strParam)
        {
            return CWholesalers.CancelArrivalOrdersNew(strParam);
        }
        /// <summary>
        /// 修改运费
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyFreightOrdersNew(string strParam)
        {
            return CWholesalers.ModifyFreightOrdersNew(strParam);
        }
        /// <summary>
        /// 作废订单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string CancelOrdersNew(string strParam)
        {
            return CWholesalers.CancelOrdersNew(strParam);
        }
        /// <summary>
        /// 出货
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ShipOrdersNew(string strParam)
        {
            return CWholesalers.ShipOrdersNew(strParam);
        }
        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string DelOrdersNew(string strParam)
        {
            return CWholesalers.DelOrdersNew(strParam);
        }
        /// <summary>
        /// 修改备注
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyRemarksOrdersNew(string strParam)
        {
            return CWholesalers.ModifyRemarksOrdersNew(strParam);
        }
        /// <summary>
        /// 制作出货单
        /// </summary>
        /// <param name="addShipParam"></param>
        /// <returns></returns>
        public string AddShipOrderNew(string strParam)
        {
            return CWholesalers.AddShipOrderNew(strParam);
        }
        /// <summary>
        /// 优惠
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ReviseOrdersNew(string strParam)
        {
            return CWholesalers.ReviseOrdersNew(strParam);
        }
        /// <summary>
        /// 售价
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyConfirmPriceOrdersNew(string strParam)
        {
            return CWholesalers.ModifyConfirmPriceOrdersNew(strParam);
        }
        /// <summary>
        /// 自留
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyOnlineOrderNew(string strParam)
        {
            return CWholesalers.ModifyOnlineOrderNew(strParam);
        }
        /// <summary>
        /// 回库
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ReturnCenter(string strParam)
        {
            return CWholesalers.ReturnCenter(strParam);
        }
        /// <summary>
        /// 收款  1人民币 2美金
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ReceiptOrdersNew(string strParam)
        {
            return CWholesalers.ReceiptOrdersNew(strParam);
        }
        /// <summary>
        /// 付款 1人民币 2美金
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string PayOrdersNew(string strParam)
        {
            return CWholesalers.PayOrdersNew(strParam);
        }
        /// <summary>
        /// 退回供应商
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ReturnOrdersNew(string strParam)
        {
            return CWholesalers.ReturnOrdersNew(strParam);
        }
        /// <summary>
        /// 订单个数统计
        /// </summary>
        /// <returns></returns>
        public string GetOrderNewNumber(string strParam)
        {
            return CWholesalers.GetOrderNewNumber(strParam);
        }
        /// <summary>
        /// 订单收款状态数统计
        /// </summary>
        /// <returns></returns>
        public string GetOrderNewReceiptStatusNumber(string strParam)
        {
            return CWholesalers.GetOrderNewReceiptStatusNumber(strParam);
        }
        /// <summary>
        /// 导出销售订单（团队）
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string DownloadSalesOrderNew(string strParam)
        {
            return CWholesalers.DownloadSalesOrderNew(strParam);
        }
        /// <summary>
        /// 导出销售和采购订单（团队）
        /// </summary>
        /// <returns></returns>
        public string DownloadSalesPurchaseOrderNew(string strParam)
        {
            return CWholesalers.DownloadSalesPurchaseOrderNew(strParam);
        }
        /// <summary>
        /// 导出所有订单
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ExportAllOrderNew(string strParam)
        {
            return CWholesalers.ExportAllOrderNew(strParam);
        }
        /// <summary>
        /// 查询购物车商品数量
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetCartNums(string strParam)
        {
            return CWholesalers.GetCartNums(strParam);
        }
        /// <summary>
        /// 打印出货单 20180903
        /// </summary>
        /// <param name="deliveryOrdersParam"></param>
        /// <returns></returns>
        public string GetPrintShipOrdersById(string strParam)
        {
            return CWholesalers.GetPrintShipOrdersById(strParam);
        }
        /// <summary>
        ///  出货单列表
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetAllShipOrder(string strParam)
        {
            return CWholesalers.GetAllShipOrder(strParam);
        }
        /// <summary>
        /// 出货单明细
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetAllShipOrderByShipNo(string strParam)
        {
            return CWholesalers.GetAllShipOrderByShipNo(strParam);
        }
        /// <summary>
        /// 删除出货单里面的订单
        /// </summary>
        /// <param name="CancelGemOrdersParam"></param>
        /// <returns></returns>
        public string UpdateOrderInShipNoByOrderIdsOrShipNo(string strParam)
        {
            return CWholesalers.UpdateOrderInShipNoByOrderIdsOrShipNo(strParam);
        }
        /// <summary>
        /// 移除购物车
        /// </summary>
        /// <param name="ringCartId"></param>
        /// <returns></returns>
        public string RemoveParcelsCart(string removeFromCartParam)
        {
            return CommonCart.DelCartInfo(GoodsType.Parcel, removeFromCartParam);
        }
        /// <summary>
        /// 移除购物车
        /// </summary>
        /// <param name="ringCartId"></param>
        /// <returns></returns>
        public string RemoveRingsCart(string removeFromCartParam)
        {
            return CommonCart.DelCartInfo(GoodsType.Ring, removeFromCartParam);
        }
        /// <summary>
        /// 移除购物车
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public string RemoveCart(string strParam)
        {
            return CWholesalers.RemoveCart(strParam);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="strParam"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public string PutPrimeGoldsPrice(string strParam)
        {
            return CWholesalers.PutPrimeGoldsPrice(strParam);
        }
        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetPrimeGoldsPrice(string strParam)
        {
            return CWholesalers.GetPrimeGoldsPrice(strParam);
        }
        /// <summary>
        /// 查询所有商品库存 TAG
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetAllProducts(string strParam)
        {
            return CWholesalers.GetAllProducts(strParam);
        }
        /// <summary>
        /// 获取供应商的倍率
        /// </summary>
        /// <param name="Supplier"></param>
        /// <param name="goodsType"></param>
        /// <returns></returns>
        public decimal GetSuppplierRate(string tttagKey, string supplier, int goodsType)
        {
            return CWholesalers.GetSuppplierRate(tttagKey, supplier, goodsType);
        }
        #endregion
        #region 添加购物车
        public string AddRingsCart(string strParam)
        {
            return CommonCart.AddCartInfo(GoodsType.Ring, strParam);
        }
        public string AddParcelsCart(string strParam)
        {
            return CommonCart.AddCartInfo(GoodsType.Parcel, strParam);
        }
        public string AddGemsCart(string strParam)
        {
            return CommonCart.AddCartInfo(GoodsType.Gem, strParam);
        }
        public string AddEmeraldsCart(string strParam)
        {
            return CommonCart.AddCartInfo(GoodsType.Emerald, strParam);
        }
        public string AddPrimeGoldsCart(string strParam)
        {
            return CommonCart.AddCartInfo(GoodsType.PrimeGolds, strParam);
        }
        public string AddInlaySettingsCart(string strParam)
        {
            return CommonCart.AddCartInfo(GoodsType.InlaySettings, strParam);
        }
        #endregion
        #region 现货批量修改
        /// <summary>
        /// 批量修改商品
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ModifyProducts(string strParam)
        {
            return CWholesalers.ModifyProducts(strParam);
        }
        /// <summary>
        /// 批量修改商品
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string DelteProducts(string strParam)
        {
            return CWholesalers.DelteProducts(strParam);
        }
        /// <summary>
        /// 更新付款状态
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public string UpdateProductPayStatus(string strParam)
        {
            return CWholesalers.UpdateProductPayStatus(strParam);
        }
        /// <summary>
        /// 批量改价  
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string UpdateProductPrice(string strParam)
        {
            return CWholesalers.UpdateProductPrice(strParam);
        }
        /// <summary>
        ///  上下架
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ShelvesProducts(string strParam)
        {
            logParam = strParam;
            HashParam hsParam = Json.Deserialize<HashParam>(strParam);
            string tttagKey = CommonUrl.getURL(hsParam, strParam, "全部上下架new");
            #region 获取产品类别 和接口Url
            if (!hsParam.ContainsKey("GoodsType"))
            {
                return CommonLog.MsgErrorInfo("未指定商品类别");
            }
            int goodsType = hsParam.GetInt("GoodsType").Value;
            hsParam.Remove("GoodsType");
            strParam = JsonConvert.SerializeObject(hsParam);
            string filterUrl = GoodsType.GetGoodsURL(goodsType);
            #endregion
            var partUrl = "";  //参数部分URL
            var lib = "0";//0白钻 ,1彩
            try
            {
                string guid = Guid.NewGuid().ToString();
                int totalSeconds;
                var lastStr = "";
                //是否传参
                if (strParam != "")
                {
                    JObject obj = JsonConvert.DeserializeObject<JObject>(strParam);
                    lastStr = MyHttpRequest.NestedDictSort2Str(obj);
                    lib = obj["IsFancy"].ToString();
                    partUrl = "?IsFancy=" + lib;
                }
                string signStr;
                MyHttpRequest.SignByParams(guid, lastStr, tttagKey, out totalSeconds, out signStr);  // 
                RequestInfo rif = new RequestInfo() { RequestJson = strParam == "" ? "{}" : strParam, RequestUrl = string.Format(GlobalConfig.OnShelvesOrOffShelvesUrl, partUrl) }; //需要更新地址中的ID
                var responseJson = MyHttpRequest.PostJSONByRequestParam(rif, 3, guid, signStr, totalSeconds, null, Yunzuan.Foundation.Web_api.MyHttpRequest.RequestLib.POST); //
                if (responseJson.Contains(".py"))
                {
                    responseJson = CommonLog.MsgErrorInfo("远程服务错误");
                }
                else if (responseJson.Contains("true"))
                {
                    responseJson = CommonLog.MsgSuccessInfo((lib == "0" ? "白钻" : "彩钻") + "上架成功");
                }
                CommonLog.SendMQMsg(tttagKey, "上架:数据中心返回结果" + responseJson);
                return responseJson;
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：上架" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo((partUrl == "" ? "全部" : lib == "0" ? "全部白钻" : "全部彩钻") + "上架失败，程序错误");
            }
        }
        #endregion
        #region 获取需要显示的供应商
        /// <summary>
        ///  只显示设置好的供应商
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ReturnSupplier(string strParam)
        { 
            return AllPublic.ReturnSupplier(strParam);
        }
        /// <summary>
        /// 获取原数据库中已开供应商的名称
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetSupplierName(int supplierType, string key)
        {
            return AllPublic.GetSupplierName(supplierType, key);
        }
        #endregion
        #region 获取用户日志  和 备注
        /// <summary>
        ///  获取用户查询次数
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetSearchCount(string strParam)
        {
            return AllPublic.GetSearchCount(strParam);
        }
        /// <summary>
        /// 获取用户查询明细
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetSearchCountDetail(string strParam)
        {
            return AllPublic.GetSearchCountDetail(strParam);
        }
        /// <summary>
        /// 添加客户备注
        /// </summary>
        /// <param name="strParam"></param>
        public string AddCustomerRemarks(string strParam)
        {
            logParam = strParam;
                HashParam hsParam = Json.Deserialize<HashParam>(strParam);
            string tttagKey = CommonUrl.getURL(hsParam,strParam, "添加客户备注");
            try
            {
                CustomerRemarks remarks = new CustomerRemarks();
                remarks.remarks = hsParam.GetString("Remarks");
                remarks.userID = hsParam.GetInt("UserID").Value;
                remarks.customerID = hsParam.GetInt("CustomerID").Value;
                remarks.CreateTime = DateTime.Now;
                int i = YZ.GetDatabase(tttagKey).Add(remarks);
                if (i > 0)
                    return CommonLog.MsgSuccessInfo("添加客户备注成功");
                else
                    return CommonLog.MsgErrorInfo("添加客户备注失败");
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：添加客户备注异常" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("程序错误");
            }
        }
        /// <summary>
        /// 插入客户日志
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string GetCustomerRemarksList(string strParam)
        {
            logParam = strParam;
                HashParam hsParam = Json.Deserialize<HashParam>(strParam);
            string tttagKey =  CommonUrl.getURL(hsParam,strParam);;
            try
            {
                if (!hsParam.ContainsKey("CustomerID"))
                    return CommonLog.MsgErrorInfo("未指定客户ID");
                IList<CustomerRemarksResult> list = YZ.GetDatabase(tttagKey).QueryForList<CustomerRemarksResult>("CustomerRemarks.GetCustomerRemarksByID", hsParam);
                return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(list));
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(this.GetType(), ex);
                CommonLog.SendMQMsg(tttagKey, "异常信息：获取客户备注异常" + ex.StackTrace + "参数:" + logParam);
                return CommonLog.MsgErrorInfo("程序错误");
            }
        }
        #endregion
        #region
        //发送验证码 
        public string ValidateCode(string strParam)
        {
            return CWholesalers.ValidateCode(strParam);
            //客户
        }
        /// <summary>
        /// 验证用户手机是否已存在（除自己外）
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string ValidateCustomerMobileIsExist(string strParam)
        {
            return CWholesalers.ValidateCustomerMobileIsExist(strParam);
        }
        /// <summary>
        /// 手机验证码登录
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string MobileLogin(string strParam)
        {
            return CWholesalers.MobileLogin(strParam);
        }
        /// <summary>
        /// 删除首页图片
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string RemoveHomeImg(string strParam)
        {
            return CWholesalers.RemoveHomeImg(strParam);
        }
        #endregion
        #region 黑名单，禁止访问的客户IP和手机号码
        public string ShowBlackList()
        {
            return ConmonMQMsgClass.SearchBlackList();
        }
        public string AddBlackList(string strParam)
        {
            return ConmonMQMsgClass.AddBlackList(strParam);
        }
        public string DelBlackList(string strParam)
        {
            return ConmonMQMsgClass.DelBlackList(strParam);
        }
        #endregion
        #region 批量上传图片视频
        /// <summary>
        /// 批量上传图片视频
        /// </summary>
        /// <param name="imageParam"></param>
        /// <returns></returns>
        public UpFileResult UploadImagesAndVideos(ImageUploadMessage imageParam)
        {
            return CWholesalers.UploadImagesAndVideos(imageParam);
        }
        #endregion
        #region 导出Excel
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="exportParam"></param>
        /// <returns></returns>
        public string ExportProductData(string strParam)
        {
            return CWholesalers.ExportProductData(strParam);
        }
        #endregion
        #region 设置客户登录方式和代下单的倍率 设置推荐
        public string AddLoginMode(string strParam)
        {
            return CWholesalers.AddLoginMode(strParam);
        }
        public string GetLoginMode(string strParam)
        {
            return CWholesalers.GetLoginMode(strParam);
        }
        public string ModifyLoginMode(string strParam)
        {
            return CWholesalers.ModifyLoginMode(strParam);
        }
        public string AddOrderRate(string strParam)
        {
            return CWholesalers.AddOrderRate(strParam);
        }
        public string GetOrderRate(string strParam)
        {
            return CWholesalers.GetOrderRate(strParam);
        }
        public string ModifyOrderRate(string strParam)
        {
            return CWholesalers.ModifyOrderRate(strParam);
        }
        public string AddRecommend(string strParam)
        {
            return CWholesalers.AddRecommend(strParam);
        }
        public string DelRecommend(string strParam)
        {
            return CWholesalers.DelRecommend(strParam);
        }
        public string GetRecommend(string strParam)
        {
            return CWholesalers.GetRecommend(strParam);
        }
        public string ModifyRecommend(string strParam)
        {
            return CWholesalers.ModifyRecommend(strParam);
        }
        #endregion
        #region  小程序相关 
        public string CheckBindByParam(string user, string key)
        {
            return CWholesalers.CheckBindByParam(user, key);
        }
        /// <summary>
        /// 绑定客户信息
        /// </summary>
        /// <param name="user"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public string BindByParam(string customerAndOpenId, string key)
        {
            return CWholesalers.BindByParam(customerAndOpenId, key);
        }
        #region 购物车
        /// <summary>
        /// 加入购物车
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string AddCart(string strParam)
        {
            int goodType = 0;
            HashParam HsParam = Json.Deserialize<HashParam>(strParam);
            if (string.IsNullOrEmpty(HsParam.GetString("GoodsTypeID")))
            {
                return CommonLog.MsgErrorInfo("请选择添加的商品");
            }
            else
            {
                goodType = HsParam.GetInt("GoodsTypeID").Value;
            }
            //Diamond = 1; //裸钻
            //Parcel = 2;//统包
            //Ring = 3;//成品
            //Gem = 4;//彩宝
            //Emerald = 5;//翡翠 
            //PrimeGolds = 6;//素金  
            //InlaySettings = 7;//空托
            //Other = 8;//其他  
            return CommonCart.AddCartInfo(goodType, strParam);
        }
        /// <summary>
        ///  删除购物车
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public string DeleteCart(string strParam)
        {
            return AllPublic.DeleteCart(strParam);
        }
        /// <summary>
        /// 更新订单
        /// </summary>
        /// <param name="selectParam"></param>
        /// <returns></returns>
        public string UpdateProductsOrder(string strParam)
        {
            return AllPublic.UpdateProductsOrder(strParam);
        }
        /// <summary>
        /// 查询订单根据条件
        /// </summary>
        /// <param name="selectParam"></param>
        /// <returns></returns>
        public string GetAllOrdersList(string strParam)
        {
            logParam = strParam;
            string tttagKey =  CommonUrl.getURL(null, strParam);;
            //Hashtable param = MyHashtable.NewHashtable(Json.Deserialize<Hashtable>(strParam));
            PageParamOfOrder param = Json.Deserialize<PageParamOfOrder>(strParam);
            try
            {
                //IList<OrderInfoResult> list = YZ.GetDatabase(tttagKey).QueryForList<OrderInfoResult>("Order.GetOrders", param);
                var list = YZ.GetDatabase(tttagKey).QueryForList<OrderInfo>("Order.GetOrders", param, param.pageSize, param.pageIndex);
                if (list != null)
                {
                    return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(list));
                }
                return CommonLog.MsgErrorInfo("未查询到订单");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 单个订单
        /// </summary>
        /// <param name="orderInfoParam"></param>
        /// <returns></returns>
        public string GetRingOrderInfo(string orderInfoParam)
        {
            return AllPublic.GetRingOrderInfo<OrderInfo>(orderInfoParam);
        }
        /// <summary>
        /// 查询购物车
        /// </summary>
        /// <param name="selectParam"></param>
        /// <returns></returns>
        public string GetAllCartsList(string strParam)
        {
            logParam = strParam;
            var _logParam = strParam;
            Hashtable param = MyHashtable.NewHashtable(Json.Deserialize<Hashtable>(strParam));
            string tttagKey =  CommonUrl.getURL(null,strParam);;
            int.TryParse(param["CustomerID"].ToString(), out int customerId);
            CustomerInfo customer = YZ.GetDatabase(tttagKey).Get<CustomerInfo>(customerId);//CustomerID必传
            IList<Cart> cartList = YZ.GetDatabase(tttagKey).QueryForList<Cart>("Cart.GetCart", param);
            Dictionary<string, object> dic2 = new Dictionary<string, object>();
            foreach (var item in cartList)
            {
                int systemSettingType = (int)item.GoodsTypeID;
                ProductList<object> list = JsonConvert.DeserializeObject<ProductList<object>>(CommonCart.SearchCartInfo((int)systemSettingType, _logParam, cartList));
                dic2.Add(systemSettingType.ToString(), list);
            }
            if (dic2.Count > 0)
                return CommonLog.MsgSuccessObj(JsonConvert.SerializeObject(dic2));
            else
                return CommonLog.MsgErrorInfo("未添加商品到购物车");
        }
        #endregion
        #endregion
    }
}
